@@ -41,8 +41,23 @@ def basic_body_verification(body, url, is_json_check=True):
4141 # they do not need or expect a dict back
4242 return None , []
4343
44+ def verify_status (request_headers_and_body_and_status , status , url , expected_status = 200 ):
45+ '''
46+ Verifies the status code of a framework response
47+ '''
48+
49+ problems = []
50+
51+ if status is not expected_status :
52+ problems .append ((
53+ 'fail' ,
54+ 'Invalid response status, found \" %s\" , did not match \" %s\" '
55+ % (status , expected_status ), url ))
56+
57+ return problems
58+
4459
45- def verify_headers (request_headers_and_body , headers , url , should_be = 'json' ):
60+ def verify_headers (request_headers_and_body_and_status , headers , url , should_be = 'json' ):
4661 '''
4762 Verifies the headers of a framework response
4863 param `should_be` is a switch for the three acceptable content types
@@ -76,7 +91,7 @@ def verify_headers(request_headers_and_body, headers, url, should_be='json'):
7691 # Verify response content
7792 # Make sure that the date object isn't cached
7893 sleep (3 )
79- second_headers , body2 = request_headers_and_body (url )
94+ second_headers , body2 , status2 = request_headers_and_body_and_status (url )
8095 second_date = second_headers .get ('Date' )
8196
8297 date2 = second_headers .get ('Date' )
@@ -349,7 +364,7 @@ def verify_query_cases(self, cases, url, check_updates=False):
349364
350365 for q , max_infraction in cases :
351366 case_url = url + q
352- headers , body = self .request_headers_and_body (case_url )
367+ headers , body , status = self .request_headers_and_body_and_status (case_url )
353368
354369 try :
355370 queries = int (q ) # drops down for 'foo' and ''
@@ -363,7 +378,7 @@ def verify_query_cases(self, cases, url, check_updates=False):
363378
364379 problems += verify_randomnumber_list (expected_len , headers , body ,
365380 case_url , max_infraction )
366- problems += verify_headers (self .request_headers_and_body , headers , case_url )
381+ problems += verify_headers (self .request_headers_and_body_and_status , headers , case_url )
367382
368383 # Only check update changes if we are doing an Update verification and if we're testing
369384 # the highest number of queries, to ensure that we don't accidentally FAIL for a query
@@ -393,7 +408,7 @@ def verify_query_cases(self, cases, url, check_updates=False):
393408 # parameter input
394409 problems += verify_randomnumber_list (
395410 expected_len , headers , body , case_url , max_infraction )
396- problems += verify_headers (self .request_headers_and_body , headers , case_url )
411+ problems += verify_headers (self .request_headers_and_body_and_status , headers , case_url )
397412
398413 if hasattr (self , 'database' ):
399414 # verify the number of queries and rows read for 20 queries, with a concurrency level of 512, with 2 repetitions
0 commit comments