mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-22 01:26:49 +03:00
Clean up test
This commit is contained in:
parent
be289d2855
commit
a4c6838762
|
@ -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))
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user