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:
Tonye Jack 2021-01-15 14:29:28 -05:00 committed by GitHub
parent bcc7f85dad
commit 135fe15ec3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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