mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 20:27:03 +03:00
77 lines
2.0 KiB
Python
77 lines
2.0 KiB
Python
from ..data import setup
|
|
from ..schema import schema
|
|
|
|
setup()
|
|
|
|
|
|
def test_mutations():
|
|
query = '''
|
|
mutation MyMutation {
|
|
introduceShip(input:{clientMutationId:"abc", shipName: "Peter", factionId: "1"}) {
|
|
ship {
|
|
id
|
|
name
|
|
}
|
|
faction {
|
|
name
|
|
ships {
|
|
edges {
|
|
node {
|
|
id
|
|
name
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
'''
|
|
expected = {
|
|
'introduceShip': {
|
|
'ship': {
|
|
'id': 'U2hpcDo5',
|
|
'name': 'Peter'
|
|
},
|
|
'faction': {
|
|
'name': 'Alliance to Restore the Republic',
|
|
'ships': {
|
|
'edges': [{
|
|
'node': {
|
|
'id': 'U2hpcDox',
|
|
'name': 'X-Wing'
|
|
}
|
|
}, {
|
|
'node': {
|
|
'id': 'U2hpcDoy',
|
|
'name': 'Y-Wing'
|
|
}
|
|
}, {
|
|
'node': {
|
|
'id': 'U2hpcDoz',
|
|
'name': 'A-Wing'
|
|
}
|
|
}, {
|
|
'node': {
|
|
'id': 'U2hpcDo0',
|
|
'name': 'Millenium Falcon'
|
|
}
|
|
}, {
|
|
'node': {
|
|
'id': 'U2hpcDo1',
|
|
'name': 'Home One'
|
|
}
|
|
}, {
|
|
'node': {
|
|
'id': 'U2hpcDo5',
|
|
'name': 'Peter'
|
|
}
|
|
}]
|
|
},
|
|
}
|
|
}
|
|
}
|
|
result = schema.execute(query)
|
|
# raise result.errors[0].original_error, None, result.errors[0].stack
|
|
assert not result.errors
|
|
assert result.data == expected
|