@@ -185,6 +185,17 @@ def was_called(fake):
185
185
self .assertTrue (was_called (self .instrumented_format_output ))
186
186
self .assertTrue (was_called (self .instrumented_retrieve_handler ))
187
187
188
+ def assertResponseStatus (self , expected_status_code ):
189
+ def called_once (fake ):
190
+ assert hasattr (fake , 'calls' )
191
+ return len (fake .calls ) == 1
192
+
193
+ self .assertTrue (called_once (self .fake_start_response ))
194
+ thecall = self .fake_start_response .calls [0 ]
195
+ wsgi_status = thecall [0 ]
196
+ actual_status_code = int (wsgi_status [0 :3 ])
197
+ self .assertEqual (actual_status_code , expected_status_code )
198
+
188
199
def assertIsValidHtmlDocument (self , value ):
189
200
assert isinstance (value , type (u"" ))
190
201
assert value .startswith ("<!DOCTYPE" )
@@ -199,10 +210,12 @@ def before_each(self):
199
210
def fake_start_response (status , headers , exc = None ):
200
211
fake_start_response .calls .append ((status , headers , exc ))
201
212
fake_start_response .calls = []
213
+ self .fake_start_response = fake_start_response
202
214
203
215
def fake_set_environ (value ):
204
216
fake_set_environ .calls .append ((value ))
205
217
fake_set_environ .calls = []
218
+ self .fake_set_environ = fake_set_environ
206
219
207
220
fake_wsgi_environ = create_wsgi_environ (_TEST_CONF_FILE , wsgi_variables = dict (
208
221
http_host = 'localhost' ,
@@ -219,7 +232,21 @@ def fake_set_environ(value):
219
232
_set_environ = fake_set_environ ,
220
233
)
221
234
222
- def test_creates_valid_html_page_for_return_value_ok (self ):
235
+ def test_return_value_ok_returns_status_200 (self ):
236
+ application_result = migwsgi ._application (
237
+ * self .application_args ,
238
+ _wrap_wsgi_errors = noop ,
239
+ _config_file = _TEST_CONF_FILE ,
240
+ _skip_log = True ,
241
+ ** self .application_kwargs
242
+ )
243
+
244
+ output = _unpack_result (application_result )
245
+
246
+ self .assertInstrumentation ()
247
+ self .assertResponseStatus (200 )
248
+
249
+ def test_return_value_ok_creates_valid_html_page (self ):
223
250
application_result = migwsgi ._application (
224
251
* self .application_args ,
225
252
_wrap_wsgi_errors = noop ,
0 commit comments