2016-09-18 02:29:00 +03:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from ..data import initialize
|
|
|
|
from ..schema import schema
|
|
|
|
|
|
|
|
pytestmark = pytest.mark.django_db
|
|
|
|
|
|
|
|
|
|
|
|
def test_mutations():
|
|
|
|
initialize()
|
|
|
|
|
2019-06-11 06:54:30 +03:00
|
|
|
query = """
|
2016-09-18 02:29:00 +03:00
|
|
|
mutation MyMutation {
|
|
|
|
introduceShip(input:{clientMutationId:"abc", shipName: "Peter", factionId: "1"}) {
|
|
|
|
ship {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
faction {
|
|
|
|
name
|
|
|
|
ships {
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-11 06:54:30 +03:00
|
|
|
"""
|
2016-09-18 02:29:00 +03:00
|
|
|
expected = {
|
2019-06-11 06:54:30 +03:00
|
|
|
"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"}},
|
2023-09-06 10:29:58 +03:00
|
|
|
{"node": {"id": "U2hpcDo0", "name": "Millennium Falcon"}},
|
2019-06-11 06:54:30 +03:00
|
|
|
{"node": {"id": "U2hpcDo1", "name": "Home One"}},
|
|
|
|
{"node": {"id": "U2hpcDo5", "name": "Peter"}},
|
|
|
|
]
|
2016-09-18 02:29:00 +03:00
|
|
|
},
|
2019-06-11 06:54:30 +03:00
|
|
|
},
|
2016-09-18 02:29:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|