2015-09-30 09:50:23 +03:00
|
|
|
import pytest
|
2015-09-30 09:40:40 +03:00
|
|
|
|
2015-10-31 23:46:43 +03:00
|
|
|
from ..data import initialize
|
2015-10-28 09:56:24 +03:00
|
|
|
from ..schema import schema
|
2015-09-30 09:40:40 +03:00
|
|
|
|
2015-09-30 09:50:23 +03:00
|
|
|
pytestmark = pytest.mark.django_db
|
2015-09-30 09:40:40 +03:00
|
|
|
|
2015-10-03 08:17:51 +03:00
|
|
|
|
2015-09-30 09:50:23 +03:00
|
|
|
def test_correctly_fetches_id_name_rebels():
|
|
|
|
initialize()
|
|
|
|
query = '''
|
|
|
|
query RebelsQuery {
|
|
|
|
rebels {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
expected = {
|
2015-10-03 08:17:51 +03:00
|
|
|
'rebels': {
|
|
|
|
'id': 'RmFjdGlvbjox',
|
|
|
|
'name': 'Alliance to Restore the Republic'
|
|
|
|
}
|
2015-09-30 09:50:23 +03:00
|
|
|
}
|
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|
2015-09-30 09:40:40 +03:00
|
|
|
|
2015-10-03 08:17:51 +03:00
|
|
|
|
2015-09-30 09:50:23 +03:00
|
|
|
def test_correctly_refetches_rebels():
|
|
|
|
initialize()
|
|
|
|
query = '''
|
|
|
|
query RebelsRefetchQuery {
|
|
|
|
node(id: "RmFjdGlvbjox") {
|
|
|
|
id
|
|
|
|
... on Faction {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
expected = {
|
2015-10-03 08:17:51 +03:00
|
|
|
'node': {
|
|
|
|
'id': 'RmFjdGlvbjox',
|
|
|
|
'name': 'Alliance to Restore the Republic'
|
|
|
|
}
|
2015-09-30 09:50:23 +03:00
|
|
|
}
|
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|
2015-09-30 09:40:40 +03:00
|
|
|
|
2015-10-03 08:17:51 +03:00
|
|
|
|
2015-09-30 09:50:23 +03:00
|
|
|
def test_correctly_fetches_id_name_empire():
|
|
|
|
initialize()
|
|
|
|
query = '''
|
|
|
|
query EmpireQuery {
|
|
|
|
empire {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
expected = {
|
2015-10-03 08:17:51 +03:00
|
|
|
'empire': {
|
|
|
|
'id': 'RmFjdGlvbjoy',
|
|
|
|
'name': 'Galactic Empire'
|
|
|
|
}
|
2015-09-30 09:50:23 +03:00
|
|
|
}
|
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|
2015-09-30 09:40:40 +03:00
|
|
|
|
2015-10-03 08:17:51 +03:00
|
|
|
|
2015-09-30 09:50:23 +03:00
|
|
|
def test_correctly_refetches_empire():
|
|
|
|
initialize()
|
|
|
|
query = '''
|
|
|
|
query EmpireRefetchQuery {
|
|
|
|
node(id: "RmFjdGlvbjoy") {
|
|
|
|
id
|
|
|
|
... on Faction {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
expected = {
|
2015-10-03 08:17:51 +03:00
|
|
|
'node': {
|
|
|
|
'id': 'RmFjdGlvbjoy',
|
|
|
|
'name': 'Galactic Empire'
|
|
|
|
}
|
2015-09-30 09:50:23 +03:00
|
|
|
}
|
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|
|
|
|
|
2015-10-03 08:17:51 +03:00
|
|
|
|
2015-09-30 09:50:23 +03:00
|
|
|
def test_correctly_refetches_xwing():
|
|
|
|
initialize()
|
|
|
|
query = '''
|
|
|
|
query XWingRefetchQuery {
|
|
|
|
node(id: "U2hpcDox") {
|
|
|
|
id
|
|
|
|
... on Ship {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
expected = {
|
2015-10-03 08:17:51 +03:00
|
|
|
'node': {
|
|
|
|
'id': 'U2hpcDox',
|
|
|
|
'name': 'X-Wing'
|
|
|
|
}
|
2015-09-30 09:50:23 +03:00
|
|
|
}
|
|
|
|
result = schema.execute(query)
|
|
|
|
assert not result.errors
|
|
|
|
assert result.data == expected
|