@@ -2941,6 +2941,39 @@ def testRenderAltTemplates(self):
2941
2941
sha1sum = '<!-- SHA: 952568414163cd12b2e89e91e59ef336da64fbbe -->'
2942
2942
self .assertNotEqual (- 1 , result .index (sha1sum ))
2943
2943
2944
+ def testRenderAltTemplatesError (self ):
2945
+ # check that an error is reported to user when rendering using
2946
+ # @template=oktempl|errortmpl|oops|foo
2947
+
2948
+ # template names can not include |
2949
+
2950
+ # set up the client;
2951
+ # run determine_context to set the required client attributes
2952
+ # run renderContext(); check result for proper page
2953
+
2954
+ # Test ok state template that uses user.forgotten.html
2955
+ self .client .form = db_test_base .makeForm ({"@template" : "forgotten|item|oops|foo" })
2956
+ self .client .path = 'user'
2957
+ self .client .determine_context ()
2958
+ self .client .session_api = MockNull (_sid = "1234567890" )
2959
+ self .assertEqual (
2960
+ (self .client .classname , self .client .template , self .client .nodeid ),
2961
+ ('user' , 'forgotten|item|oops|foo' , None ))
2962
+ self .assertEqual (self .client ._ok_message , [])
2963
+
2964
+ result = self .client .renderContext ()
2965
+ print (result )
2966
+ # sha1sum of classic tracker user.forgotten.template must be found
2967
+ sha1sum = '<!-- SHA: f93570f95f861da40f9c45bbd2b049bb3a7c0fc5 -->'
2968
+ self .assertNotEqual (- 1 , result .index (sha1sum ))
2969
+
2970
+ # now set an error in the form to get error template user.item.html
2971
+ self .client .form = db_test_base .makeForm ({"@template" : "forgotten|item|oops|foo" ,
2972
+ "@error_message" : "this is an error" })
2973
+ self .client .path = 'user'
2974
+ self .client .determine_context ()
2975
+ result = self .client .renderContext ()
2976
+ self .assertEqual (result , '<strong>No template file exists for templating "user" with template "item|oops|foo" (neither "user.item|oops|foo" nor "_generic.item|oops|foo")</strong>' )
2944
2977
2945
2978
def testexamine_url (self ):
2946
2979
''' test the examine_url function '''
0 commit comments