mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-09-21 11:29:09 +03:00
Python 2.7 syntax compat
This commit is contained in:
parent
b491878c27
commit
3c11a980fe
|
@ -17,14 +17,14 @@ class GraphQLTestCase(TestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super().setUpClass()
|
super(GraphQLTestCase, cls).setUpClass()
|
||||||
|
|
||||||
if not cls.GRAPHQL_SCHEMA:
|
if not cls.GRAPHQL_SCHEMA:
|
||||||
raise AttributeError('Variable GRAPHQL_SCHEMA not defined in GraphQLTestCase.')
|
raise AttributeError('Variable GRAPHQL_SCHEMA not defined in GraphQLTestCase.')
|
||||||
|
|
||||||
cls._client = Client(cls.GRAPHQL_SCHEMA)
|
cls._client = Client(cls.GRAPHQL_SCHEMA)
|
||||||
|
|
||||||
def query(self, query: str, op_name: str = None, input_data: dict = None):
|
def query(self, query, op_name=None, input_data=None):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
query (string) - GraphQL query to run
|
query (string) - GraphQL query to run
|
||||||
|
@ -47,18 +47,20 @@ class GraphQLTestCase(TestCase):
|
||||||
content_type='application/json')
|
content_type='application/json')
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def assertResponseNoErrors(self, resp: HttpResponse):
|
def assertResponseNoErrors(self, resp):
|
||||||
"""
|
"""
|
||||||
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.
|
||||||
|
:resp HttpResponse: Response
|
||||||
"""
|
"""
|
||||||
content = json.loads(resp.content)
|
content = json.loads(resp.content)
|
||||||
self.assertEqual(resp.status_code, 200)
|
self.assertEqual(resp.status_code, 200)
|
||||||
self.assertNotIn('errors', list(content.keys()))
|
self.assertNotIn('errors', list(content.keys()))
|
||||||
|
|
||||||
def assertResponseHasErrors(self, resp: HttpResponse):
|
def assertResponseHasErrors(self, resp):
|
||||||
"""
|
"""
|
||||||
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
|
||||||
"""
|
"""
|
||||||
content = json.loads(resp.content)
|
content = json.loads(resp.content)
|
||||||
self.assertIn('errors', list(content.keys()))
|
self.assertIn('errors', list(content.keys()))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user