2016-07-18 18:28:12 +03:00
|
|
|
from graphene import ObjectType, Schema, String
|
|
|
|
|
|
|
|
from ..utils import get_session
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_session():
|
|
|
|
session = 'My SQLAlchemy session'
|
|
|
|
|
|
|
|
class Query(ObjectType):
|
|
|
|
x = String()
|
|
|
|
|
2016-07-23 06:18:23 +03:00
|
|
|
def resolve_x(self, args, context, info):
|
|
|
|
return get_session(context)
|
2016-07-18 18:28:12 +03:00
|
|
|
|
|
|
|
query = '''
|
|
|
|
query ReporterQuery {
|
|
|
|
x
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
|
2016-07-23 06:18:23 +03:00
|
|
|
schema = Schema(query=Query)
|
|
|
|
result = schema.execute(query, context_value={'session': session})
|
2016-07-18 18:28:12 +03:00
|
|
|
assert not result.errors
|
|
|
|
assert result.data['x'] == session
|