graphene/examples/starwars_django/tests/test_connections.py

48 lines
934 B
Python
Raw Normal View History

2015-09-30 09:50:23 +03:00
import pytest
2015-09-30 09:40:40 +03:00
from ..data import initialize
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_correct_fetch_first_ship_rebels():
initialize()
query = '''
query RebelsShipsQuery {
rebels {
name,
2015-10-11 00:53:46 +03:00
hero {
name
}
2015-09-30 09:50:23 +03:00
ships(first: 1) {
edges {
node {
name
}
}
}
}
}
'''
expected = {
2015-10-03 08:17:51 +03:00
'rebels': {
'name': 'Alliance to Restore the Republic',
2015-10-11 00:53:46 +03:00
'hero': {
'name': 'Human'
},
2015-10-03 08:17:51 +03:00
'ships': {
'edges': [
{
'node': {
'name': 'X-Wing'
}
}
]
2015-09-30 09:50:23 +03:00
}
}
}
result = schema.execute(query)
assert not result.errors
assert result.data == expected