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_correctly_fetches_id_name_rebels():
|
|
|
|
initialize()
|
2019-06-11 06:54:30 +03:00
|
|
|
query = """
|
2016-09-18 02:29:00 +03:00
|
|
|
query RebelsQuery {
|
|
|
|
rebels {
|
|
|
|
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
|
|
|
"rebels": {"id": "RmFjdGlvbjox", "name": "Alliance to Restore the Republic"}
|
2016-09-18 02:29:00 +03:00
|
|
|
}
|
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|
|
|
|
|
|
|
|
|
|
|
|
def test_correctly_refetches_rebels():
|
|
|
|
initialize()
|
2019-06-11 06:54:30 +03:00
|
|
|
query = """
|
2016-09-18 02:29:00 +03:00
|
|
|
query RebelsRefetchQuery {
|
|
|
|
node(id: "RmFjdGlvbjox") {
|
|
|
|
id
|
|
|
|
... on Faction {
|
|
|
|
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
|
|
|
"node": {"id": "RmFjdGlvbjox", "name": "Alliance to Restore the Republic"}
|
2016-09-18 02:29:00 +03:00
|
|
|
}
|
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|
|
|
|
|
|
|
|
|
|
|
|
def test_correctly_fetches_id_name_empire():
|
|
|
|
initialize()
|
2019-06-11 06:54:30 +03:00
|
|
|
query = """
|
2016-09-18 02:29:00 +03:00
|
|
|
query EmpireQuery {
|
|
|
|
empire {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
2019-06-11 06:54:30 +03:00
|
|
|
"""
|
|
|
|
expected = {"empire": {"id": "RmFjdGlvbjoy", "name": "Galactic Empire"}}
|
2016-09-18 02:29:00 +03:00
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|
|
|
|
|
|
|
|
|
|
|
|
def test_correctly_refetches_empire():
|
|
|
|
initialize()
|
2019-06-11 06:54:30 +03:00
|
|
|
query = """
|
2016-09-18 02:29:00 +03:00
|
|
|
query EmpireRefetchQuery {
|
|
|
|
node(id: "RmFjdGlvbjoy") {
|
|
|
|
id
|
|
|
|
... on Faction {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-11 06:54:30 +03:00
|
|
|
"""
|
|
|
|
expected = {"node": {"id": "RmFjdGlvbjoy", "name": "Galactic Empire"}}
|
2016-09-18 02:29:00 +03:00
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|
|
|
|
|
|
|
|
|
|
|
|
def test_correctly_refetches_xwing():
|
|
|
|
initialize()
|
2019-06-11 06:54:30 +03:00
|
|
|
query = """
|
2016-09-18 02:29:00 +03:00
|
|
|
query XWingRefetchQuery {
|
|
|
|
node(id: "U2hpcDox") {
|
|
|
|
id
|
|
|
|
... on Ship {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-11 06:54:30 +03:00
|
|
|
"""
|
|
|
|
expected = {"node": {"id": "U2hpcDox", "name": "X-Wing"}}
|
2016-09-18 02:29:00 +03:00
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|