2015-09-26 09:25:10 +03:00
|
|
|
from pytest import raises
|
|
|
|
from graphql.core import graphql
|
|
|
|
|
2015-09-28 06:19:33 +03:00
|
|
|
from .schema import schema
|
2015-09-26 09:25:10 +03:00
|
|
|
|
|
|
|
def test_correctly_fetches_id_name_rebels():
|
|
|
|
query = '''
|
|
|
|
query RebelsQuery {
|
|
|
|
rebels {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
expected = {
|
|
|
|
'rebels': {
|
|
|
|
'id': 'RmFjdGlvbjox',
|
|
|
|
'name': 'Alliance to Restore the Republic'
|
|
|
|
}
|
|
|
|
}
|
2015-09-28 06:19:33 +03:00
|
|
|
result = schema.execute(query)
|
2015-09-29 10:31:59 +03:00
|
|
|
assert not result.errors
|
2015-09-26 09:25:10 +03:00
|
|
|
assert result.data == expected
|
|
|
|
|
|
|
|
def test_correctly_refetches_rebels():
|
|
|
|
query = '''
|
|
|
|
query RebelsRefetchQuery {
|
|
|
|
node(id: "RmFjdGlvbjox") {
|
|
|
|
id
|
|
|
|
... on Faction {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
expected = {
|
|
|
|
'node': {
|
|
|
|
'id': 'RmFjdGlvbjox',
|
|
|
|
'name': 'Alliance to Restore the Republic'
|
|
|
|
}
|
|
|
|
}
|
2015-09-28 06:19:33 +03:00
|
|
|
result = schema.execute(query)
|
2015-09-29 10:31:59 +03:00
|
|
|
assert not result.errors
|
2015-09-26 09:25:10 +03:00
|
|
|
assert result.data == expected
|
|
|
|
|
|
|
|
def test_correctly_fetches_id_name_empire():
|
|
|
|
query = '''
|
|
|
|
query EmpireQuery {
|
|
|
|
empire {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
expected = {
|
|
|
|
'empire': {
|
|
|
|
'id': 'RmFjdGlvbjoy',
|
|
|
|
'name': 'Galactic Empire'
|
|
|
|
}
|
|
|
|
}
|
2015-09-28 06:19:33 +03:00
|
|
|
result = schema.execute(query)
|
2015-09-29 10:31:59 +03:00
|
|
|
assert not result.errors
|
2015-09-26 09:25:10 +03:00
|
|
|
assert result.data == expected
|
|
|
|
|
|
|
|
def test_correctly_refetches_empire():
|
|
|
|
query = '''
|
|
|
|
query EmpireRefetchQuery {
|
|
|
|
node(id: "RmFjdGlvbjoy") {
|
|
|
|
id
|
|
|
|
... on Faction {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
expected = {
|
|
|
|
'node': {
|
|
|
|
'id': 'RmFjdGlvbjoy',
|
|
|
|
'name': 'Galactic Empire'
|
|
|
|
}
|
|
|
|
}
|
2015-09-28 06:19:33 +03:00
|
|
|
result = schema.execute(query)
|
2015-09-29 10:31:59 +03:00
|
|
|
assert not result.errors
|
2015-09-26 09:25:10 +03:00
|
|
|
assert result.data == expected
|
|
|
|
|
|
|
|
def test_correctly_refetches_xwing():
|
|
|
|
query = '''
|
|
|
|
query XWingRefetchQuery {
|
|
|
|
node(id: "U2hpcDox") {
|
|
|
|
id
|
|
|
|
... on Ship {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
expected = {
|
|
|
|
'node': {
|
|
|
|
'id': 'U2hpcDox',
|
|
|
|
'name': 'X-Wing'
|
|
|
|
}
|
|
|
|
}
|
2015-09-28 06:19:33 +03:00
|
|
|
result = schema.execute(query)
|
2015-09-29 10:31:59 +03:00
|
|
|
assert not result.errors
|
2015-09-26 09:25:10 +03:00
|
|
|
assert result.data == expected
|