Mercurial > p > roundup > code
comparison test/test_cgi.py @ 6382:b35a50d02890
Fix issue2551129 - Template not found return 500 and traceback
Handle traceback caused when requested @template is not found.
Moved scope of try to include call to self.selectTemplate.
Patch provided by Cedric Krier.
Additional patch to make this case return 400 error since it
is a client caused error. Test case added.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 18 Apr 2021 20:54:48 -0400 |
| parents | f2c31f5ec50b |
| children | ada96db8ec62 |
comparison
equal
deleted
inserted
replaced
| 6381:89aa919997c0 | 6382:b35a50d02890 |
|---|---|
| 743 file = FileUpload('foo', 'foo.txt') | 743 file = FileUpload('foo', 'foo.txt') |
| 744 self.assertEqual(self.parseForm({':file': file}, 'issue'), | 744 self.assertEqual(self.parseForm({':file': file}, 'issue'), |
| 745 ({('issue', None): {}, ('file', '-1'): {'content': 'foo', | 745 ({('issue', None): {}, ('file', '-1'): {'content': 'foo', |
| 746 'name': 'foo.txt', 'type': 'text/plain'}}, | 746 'name': 'foo.txt', 'type': 'text/plain'}}, |
| 747 [('issue', None, 'files', [('file', '-1')])])) | 747 [('issue', None, 'files', [('file', '-1')])])) |
| 748 | |
| 749 def testErrorForBadTemplate(self): | |
| 750 form = {} | |
| 751 cl = self.setupClient(form, 'issue', '1', template="broken", | |
| 752 env_addon = {'HTTP_REFERER': 'http://whoami.com/path/'}) | |
| 753 out = [] | |
| 754 | |
| 755 out = cl.renderContext() | |
| 756 | |
| 757 self.assertEqual(out, '<strong>No template file exists for templating "issue" with template "broken" (neither "issue.broken" nor "_generic.broken")</strong>') | |
| 758 self.assertEqual(cl.response_code, 400) | |
| 748 | 759 |
| 749 def testFormValuePreserveOnError(self): | 760 def testFormValuePreserveOnError(self): |
| 750 page_template = """ | 761 page_template = """ |
| 751 <html> | 762 <html> |
| 752 <body> | 763 <body> |
