Skip to content

Commit a8582b9

Browse files
committed
Regression test for valid HTML being generated in the error path.
1 parent 40cb471 commit a8582b9

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/test_mig_wsgi-bin.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,42 @@ def test_return_value_ok_returns_expected_title(self):
135135
output, 'title', 'TEST', trim_newlines=True)
136136

137137

138+
class MigWsgibin_output_objects(MigTestCase, HtmlAssertMixin, WsgiAssertMixin):
139+
140+
def _provide_configuration(self):
141+
return 'testconfig'
142+
143+
def before_each(self):
144+
self.fake_backend = FakeBackend()
145+
self.fake_wsgi = prepare_wsgi(self.configuration, 'http://localhost/')
146+
147+
self.application_args = (
148+
self.configuration,
149+
self.fake_wsgi.environ,
150+
self.fake_wsgi.start_response,
151+
)
152+
self.application_kwargs = dict(
153+
configuration=self.configuration,
154+
_import_module=self.fake_backend.to_import_module(),
155+
_set_os_environ=False,
156+
)
157+
158+
def test_unknown_object_type_generates_valid_error_page(self):
159+
output_objects = [
160+
{
161+
'object_type': 'nonexistent', # trigger error handling path
162+
}
163+
]
164+
self.fake_backend.set_response(output_objects, returnvalues.OK)
165+
166+
wsgi_result = migwsgi.application(
167+
*self.application_args,
168+
**self.application_kwargs
169+
)
170+
171+
output, _ = self.assertWsgiResponse(wsgi_result, self.fake_wsgi, 200)
172+
self.assertIsValidHtmlDocument(html_output)
173+
174+
138175
if __name__ == '__main__':
139176
testmain()

0 commit comments

Comments
 (0)