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_correct_fetch_first_ship_rebels():
|
|
|
|
initialize()
|
2019-06-11 06:54:30 +03:00
|
|
|
query = """
|
2016-09-18 02:29:00 +03:00
|
|
|
query RebelsShipsQuery {
|
|
|
|
rebels {
|
|
|
|
name,
|
|
|
|
hero {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
ships(first: 1) {
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
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
|
|
|
"rebels": {
|
|
|
|
"name": "Alliance to Restore the Republic",
|
|
|
|
"hero": {"name": "Human"},
|
|
|
|
"ships": {"edges": [{"node": {"name": "X-Wing"}}]},
|
2016-09-18 02:29:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|
2016-09-22 05:32:39 +03:00
|
|
|
|
|
|
|
|
|
|
|
def test_correct_list_characters():
|
|
|
|
initialize()
|
2019-06-11 06:54:30 +03:00
|
|
|
query = """
|
2016-09-22 05:32:39 +03:00
|
|
|
query RebelsShipsQuery {
|
|
|
|
node(id: "U2hpcDox") {
|
|
|
|
... on Ship {
|
|
|
|
name
|
|
|
|
characters {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-11 06:54:30 +03:00
|
|
|
"""
|
|
|
|
expected = {"node": {"name": "X-Wing", "characters": [{"name": "Human"}]}}
|
2016-09-22 05:32:39 +03:00
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|