Updated docs.

This commit is contained in:
Tonye Jack 2021-02-06 13:08:30 -05:00
parent 6d397fae13
commit fd9209658d

View File

@ -82,6 +82,41 @@ Usage:
# Add some more asserts if you like # Add some more asserts if you like
... ...
For testing mutations that are executed within a transaction you should subclass `GraphQLTransactionTestCase`
Usage:
.. code:: python
import json
from graphene_django.utils.testing import GraphQLTransactionTestCase
class MyFancyTransactionTestCase(GraphQLTransactionTestCase):
def test_some_mutation_that_executes_within_a_transaction(self):
response = self.query(
'''
mutation myMutation($input: MyMutationInput!) {
myMutation(input: $input) {
my-model {
id
name
}
}
}
''',
op_name='myMutation',
input_data={'my_field': 'foo', 'other_field': 'bar'}
)
# This validates the status code and if you get errors
self.assertResponseNoErrors(response)
# Add some more asserts if you like
...
Using pytest Using pytest
------------ ------------
@ -117,3 +152,6 @@ To use pytest define a simple fixture using the query helper below
content = json.loads(response.content) content = json.loads(response.content)
assert 'errors' not in content assert 'errors' not in content
Running Transaction