mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-11 08:42:32 +03:00
Updated docs.
This commit is contained in:
parent
6d397fae13
commit
fd9209658d
|
@ -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
|
Loading…
Reference in New Issue
Block a user