mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-25 02:54:06 +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
58 lines
1.1 KiB
Python
58 lines
1.1 KiB
Python
import pytest
|
|
|
|
from ..data import initialize
|
|
from ..schema import schema
|
|
|
|
pytestmark = pytest.mark.django_db
|
|
|
|
|
|
def test_correct_fetch_first_ship_rebels():
|
|
initialize()
|
|
query = """
|
|
query RebelsShipsQuery {
|
|
rebels {
|
|
name,
|
|
hero {
|
|
name
|
|
}
|
|
ships(first: 1) {
|
|
edges {
|
|
node {
|
|
name
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
expected = {
|
|
"rebels": {
|
|
"name": "Alliance to Restore the Republic",
|
|
"hero": {"name": "Human"},
|
|
"ships": {"edges": [{"node": {"name": "X-Wing"}}]},
|
|
}
|
|
}
|
|
result = schema.execute(query)
|
|
assert not result.errors
|
|
assert result.data == expected
|
|
|
|
|
|
def test_correct_list_characters():
|
|
initialize()
|
|
query = """
|
|
query RebelsShipsQuery {
|
|
node(id: "U2hpcDox") {
|
|
... on Ship {
|
|
name
|
|
characters {
|
|
name
|
|
}
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
expected = {"node": {"name": "X-Wing", "characters": [{"name": "Human"}]}}
|
|
result = schema.execute(query)
|
|
assert not result.errors
|
|
assert result.data == expected
|