Clean up test

This commit is contained in:
Jonathan Kim 2020-07-12 12:45:31 +01:00
parent be289d2855
commit a4c6838762
2 changed files with 4 additions and 25 deletions

View File

@ -348,7 +348,7 @@ class TypeMap(dict):
resolver = get_unbound_function(resolver) resolver = get_unbound_function(resolver)
# TODO wrap resolver # Wrap resolver
def wrapped_resolver(*args, **kwargs): def wrapped_resolver(*args, **kwargs):
result = resolver(*args, **kwargs) result = resolver(*args, **kwargs)
return MapAsyncIterator(result, partial(map_payload_to_object, name)) return MapAsyncIterator(result, partial(map_payload_to_object, name))

View File

@ -1,44 +1,23 @@
from pytest import mark from pytest import mark
from graphene import ObjectType, Int, String, Schema from graphene import ObjectType, Int, String, Schema
from graphene.types.objecttype import ObjectTypeOptions
MYPY = False
if MYPY:
from typing import Callable # NOQA
class Query(ObjectType): class Query(ObjectType):
a = String() a = String()
class SubscriptionOptions(ObjectTypeOptions):
pass
class Subscription(ObjectType): class Subscription(ObjectType):
@classmethod count_to_ten = Int()
def __init_subclass_with_meta__(
cls, _meta=None, **options,
):
if not _meta:
_meta = SubscriptionOptions(cls)
super().__init_subclass_with_meta__(_meta=_meta, **options) async def subscribe_count_to_ten(root, info):
class MySubscription(Subscription):
count_to_ten = Int(yes=Int())
async def subscribe_count_to_ten(root, info, **kwargs):
count = 0 count = 0
while count < 10: while count < 10:
count += 1 count += 1
yield count yield count
schema = Schema(query=Query, subscription=MySubscription) schema = Schema(query=Query, subscription=Subscription)
@mark.asyncio @mark.asyncio