1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
from ..objecttype import ObjectType
from ..schema import Schema
from ..uuid import UUID
class Query(ObjectType):
uuid = UUID(input=UUID())
def resolve_uuid(self, info, input):
return input
schema = Schema(query=Query)
def test_uuidstring_query():
uuid_value = "dfeb3bcf-70fd-11e7-a61a-6003088f8204"
result = schema.execute("""{ uuid(input: "%s") }""" % uuid_value)
assert not result.errors
assert result.data == {"uuid": uuid_value}
def test_uuidstring_query_variable():
uuid_value = "dfeb3bcf-70fd-11e7-a61a-6003088f8204"
result = schema.execute(
"""query Test($uuid: UUID){ uuid(input: $uuid) }""",
variables={"uuid": uuid_value},
)
assert not result.errors
assert result.data == {"uuid": uuid_value}
|