def test_extract_error_message_from_response(self): error_message = ("Error: <html> <head> <title>400 Bad Request</title> </head> <body> <h1>400 Bad Request</h1> " "The server could not comply with the request since it is either malformed or otherwise " "incorrect.<br /><br /> Problem submitting job, unrecognised format. </body> </html>") extracted_message = extract_error_message_from_response(error_message) expected_result = "Problem submitting job, unrecognised format." assert_that(extracted_message, is_(expected_result))
def test_extract_error_message_from_response_with_unexpected_message(self): # The extract_error_message_from_response searches for a particular set of tags when filtering for the output. # This test looks at the case when those tags aren't present, and ensures that a sensible error message # is returned. error_message = ("Error: <html> <head> <title>400 Bad Request</title> </head> <body> " " Problem submitting job, unrecognised format. </body> </html>") extracted_message = extract_error_message_from_response(error_message) expected_result = "Unknown error." assert_that(extracted_message, is_(expected_result))