graphene/tests/starwars_django/test_connections.py

43 lines
801 B
Python
Raw Normal View History

2015-09-30 09:50:23 +03:00
import pytest
from graphql.core import graphql
2015-09-30 09:40:40 +03:00
2015-09-30 09:50:23 +03:00
from .models import *
from .schema import schema
from .data import initialize
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-09-30 09:50:23 +03:00
def test_correct_fetch_first_ship_rebels():
initialize()
query = '''
query RebelsShipsQuery {
rebels {
name,
ships(first: 1) {
edges {
node {
name
}
}
}
}
}
'''
expected = {
'rebels': {
'name': 'Alliance to Restore the Republic',
'ships': {
'edges': [
{
'node': {
'name': 'X-Wing'
}
}
]
}
}
}
result = schema.execute(query)
assert not result.errors
assert result.data == expected