mirror of https://github.com/zulip/zulip.git
Add methods to AuthedTestCase to test response content.
Add methods assert_equals_response and assert_in_response to AuthedTestCase. These methods make it convenient to check if a string equals the contents of an HttpResponse's body or if a string is a substring of the contents of an HttpResponse's body.
This commit is contained in:
parent
2080ff6c2a
commit
161c27d0e9
|
@ -391,6 +391,14 @@ class AuthedTestCase(TestCase):
|
|||
# type: (HttpResponse, text_type, int) -> None
|
||||
self.assertIn(msg_substring, self.get_json_error(result, status_code=status_code))
|
||||
|
||||
def assert_equals_response(self, string, response):
|
||||
# type: (text_type, HttpResponse) -> None
|
||||
self.assertEqual(string, response.content.decode('utf-8'))
|
||||
|
||||
def assert_in_response(self, substring, response):
|
||||
# type: (text_type, HttpResponse) -> None
|
||||
self.assertIn(substring, response.content.decode('utf-8'))
|
||||
|
||||
def fixture_data(self, type, action, file_type='json'):
|
||||
# type: (text_type, text_type, text_type) -> text_type
|
||||
return force_text(open(os.path.join(os.path.dirname(__file__),
|
||||
|
|
Loading…
Reference in New Issue