mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-11 00:32:24 +03:00
Added GraphQLTransactionTestCase
- Adds support for testing code that is executed within a transaction Reference: https://docs.djangoproject.com/en/3.1/topics/testing/tools/#django.test.TransactionTestCase ``` For instance, you cannot test that a block of code is executing within a transaction, as is required when using select_for_update(). In those cases, you should use TransactionTestCase. ```
This commit is contained in:
parent
bcc7f85dad
commit
135fe15ec3
|
@ -61,7 +61,7 @@ def graphql_query(
|
|||
return resp
|
||||
|
||||
|
||||
class GraphQLTestCase(TestCase):
|
||||
class GraphQLTestMixin(object):
|
||||
"""
|
||||
Based on: https://www.sam.today/blog/testing-graphql-with-graphene-django/
|
||||
"""
|
||||
|
@ -139,3 +139,12 @@ class GraphQLTestCase(TestCase):
|
|||
"""
|
||||
content = json.loads(resp.content)
|
||||
self.assertIn("errors", list(content.keys()), msg or content)
|
||||
|
||||
|
||||
class GraphQLTestCase(GraphQLTestMixin, TestCase):
|
||||
pass
|
||||
|
||||
|
||||
class GraphQLTransactionTestCase(GraphQLTestMixin, TransactionTestCase)
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user