graphene/graphene-sqlalchemy/graphene_sqlalchemy/tests/test_utils.py
2016-07-22 20:24:12 -07:00

25 lines
539 B
Python

from graphene import ObjectType, Schema, String
from ..utils import get_session
def test_get_session():
session = 'My SQLAlchemy session'
class Query(ObjectType):
x = String()
def resolve_x(self, args, context, info):
return get_session(context)
query = '''
query ReporterQuery {
x
}
'''
schema = Schema(query=Query)
result = schema.execute(query, context_value={'session': session})
assert not result.errors
assert result.data['x'] == session