def assert_response(<EOL>response,<EOL>expected_status_code,<EOL>expected_data=UNDEFINED,<EOL>get_data=get_data,<EOL>get_errors=get_errors,<EOL>):
status_code = response.status_code<EOL>assert status_code == expected_status_code<EOL>if not response.content_length:<EOL><INDENT>response_data = UNDEFINED<EOL><DEDENT>elif <NUM_LIT:200> <= response.status_code < <NUM_LIT>:<EOL><INDENT>response_data = get_data(response)<EOL><DEDENT>elif response.status_code >= <NUM_LIT>:<EOL><INDENT>response_data = get_errors(response)<EOL><DEDENT>else:<EOL><INDENT>response_data = response.data<EOL><DEDENT>if expected_data is not UNDEFINED:<EOL><INDENT>if not isinstance(expected_data, Predicate):<EOL><INDENT>expected_data = Shape(expected_data)<EOL><DEDENT>assert response_data == expected_data<EOL><DEDENT>return response_data<EOL>
Assert on the status and contents of a response.

    If specified, expected_data is checked against either the data or the
    errors in the response body, depending on the response status. This check
    ignores extra keys dictionaries in the response contents.