graphene/examples/starwars_relay/tests/test_mutation.py

77 lines
2.0 KiB
Python
Raw Normal View History

2015-10-30 10:36:31 +03:00
from ..data import setup
from ..schema import schema
2015-10-30 10:36:31 +03:00
setup()
def test_mutations():
query = '''
mutation MyMutation {
introduceShip(input:{clientMutationId:"abc", shipName: "Peter", factionId: "1"}) {
ship {
id
name
}
faction {
name
2016-06-15 09:48:25 +03:00
ships {
edges {
node {
id
name
}
}
}
2015-10-30 10:36:31 +03:00
}
}
}
'''
expected = {
'introduceShip': {
'ship': {
'id': 'U2hpcDo5',
'name': 'Peter'
},
'faction': {
'name': 'Alliance to Restore the Republic',
2016-06-15 09:48:25 +03:00
'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'
}
}]
},
2015-10-30 10:36:31 +03:00
}
}
}
result = schema.execute(query)
2016-06-10 07:18:42 +03:00
# raise result.errors[0].original_error, None, result.errors[0].stack
2015-10-30 10:36:31 +03:00
assert not result.errors
assert result.data == expected