Add msg params to testing class (#1032)

This commit is contained in:
Ülgen Sarıkavak 2020-08-26 17:58:48 +03:00 committed by GitHub
parent 6ce208db95
commit 26960359a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,7 +103,7 @@ class GraphQLTestCase(TestCase):
graphql_url=self.GRAPHQL_URL, graphql_url=self.GRAPHQL_URL,
) )
def assertResponseNoErrors(self, resp): def assertResponseNoErrors(self, resp, msg=None):
""" """
Assert that the call went through correctly. 200 means the syntax is ok, if there are no `errors`, Assert that the call went through correctly. 200 means the syntax is ok, if there are no `errors`,
the call was fine. the call was fine.
@ -111,12 +111,12 @@ class GraphQLTestCase(TestCase):
""" """
self.assertEqual(resp.status_code, 200) self.assertEqual(resp.status_code, 200)
content = json.loads(resp.content) content = json.loads(resp.content)
self.assertNotIn("errors", list(content.keys())) self.assertNotIn("errors", list(content.keys()), msg)
def assertResponseHasErrors(self, resp): def assertResponseHasErrors(self, resp, msg=None):
""" """
Assert that the call was failing. Take care: Even with errors, GraphQL returns status 200! Assert that the call was failing. Take care: Even with errors, GraphQL returns status 200!
:resp HttpResponse: Response :resp HttpResponse: Response
""" """
content = json.loads(resp.content) content = json.loads(resp.content)
self.assertIn("errors", list(content.keys())) self.assertIn("errors", list(content.keys()), msg)