mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-27 12:03:43 +03:00
775d2e3523
* Update travis and tox * Use xenial distribution * Don't install coveralls twice * Add black and flake8 tox commands * Remove Python 3.5 test for Django master * Fix indent * Ignore migrations * Remove black for now * Run black formatting (#668) * Run black format * Update makefile * Add black to travis build
97 lines
2.0 KiB
Python
97 lines
2.0 KiB
Python
import pytest
|
|
|
|
from ..data import initialize
|
|
from ..schema import schema
|
|
|
|
pytestmark = pytest.mark.django_db
|
|
|
|
|
|
def test_correctly_fetches_id_name_rebels():
|
|
initialize()
|
|
query = """
|
|
query RebelsQuery {
|
|
rebels {
|
|
id
|
|
name
|
|
}
|
|
}
|
|
"""
|
|
expected = {
|
|
"rebels": {"id": "RmFjdGlvbjox", "name": "Alliance to Restore the Republic"}
|
|
}
|
|
result = schema.execute(query)
|
|
assert not result.errors
|
|
assert result.data == expected
|
|
|
|
|
|
def test_correctly_refetches_rebels():
|
|
initialize()
|
|
query = """
|
|
query RebelsRefetchQuery {
|
|
node(id: "RmFjdGlvbjox") {
|
|
id
|
|
... on Faction {
|
|
name
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
expected = {
|
|
"node": {"id": "RmFjdGlvbjox", "name": "Alliance to Restore the Republic"}
|
|
}
|
|
result = schema.execute(query)
|
|
assert not result.errors
|
|
assert result.data == expected
|
|
|
|
|
|
def test_correctly_fetches_id_name_empire():
|
|
initialize()
|
|
query = """
|
|
query EmpireQuery {
|
|
empire {
|
|
id
|
|
name
|
|
}
|
|
}
|
|
"""
|
|
expected = {"empire": {"id": "RmFjdGlvbjoy", "name": "Galactic Empire"}}
|
|
result = schema.execute(query)
|
|
assert not result.errors
|
|
assert result.data == expected
|
|
|
|
|
|
def test_correctly_refetches_empire():
|
|
initialize()
|
|
query = """
|
|
query EmpireRefetchQuery {
|
|
node(id: "RmFjdGlvbjoy") {
|
|
id
|
|
... on Faction {
|
|
name
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
expected = {"node": {"id": "RmFjdGlvbjoy", "name": "Galactic Empire"}}
|
|
result = schema.execute(query)
|
|
assert not result.errors
|
|
assert result.data == expected
|
|
|
|
|
|
def test_correctly_refetches_xwing():
|
|
initialize()
|
|
query = """
|
|
query XWingRefetchQuery {
|
|
node(id: "U2hpcDox") {
|
|
id
|
|
... on Ship {
|
|
name
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
expected = {"node": {"id": "U2hpcDox", "name": "X-Wing"}}
|
|
result = schema.execute(query)
|
|
assert not result.errors
|
|
assert result.data == expected
|