mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-04-16 07:02:04 +03:00
Add test.
This commit is contained in:
parent
c313648096
commit
d4041f7ace
|
@ -60,6 +60,31 @@ def test_should_query_simplelazy_objects():
|
|||
assert result.data == {"reporter": {"id": "1"}}
|
||||
|
||||
|
||||
def test_should_query_wrapped_simplelazy_objects():
|
||||
class ReporterType(DjangoObjectType):
|
||||
class Meta:
|
||||
model = Reporter
|
||||
fields = ("id",)
|
||||
|
||||
class Query(graphene.ObjectType):
|
||||
reporter = graphene.Field(ReporterType)
|
||||
|
||||
def resolve_reporter(self, info):
|
||||
return SimpleLazyObject(lambda: SimpleLazyObject(lambda: Reporter(id=1)))
|
||||
|
||||
schema = graphene.Schema(query=Query)
|
||||
query = """
|
||||
query {
|
||||
reporter {
|
||||
id
|
||||
}
|
||||
}
|
||||
"""
|
||||
result = schema.execute(query)
|
||||
assert not result.errors
|
||||
assert result.data == {"reporter": {"id": "1"}}
|
||||
|
||||
|
||||
def test_should_query_well():
|
||||
class ReporterType(DjangoObjectType):
|
||||
class Meta:
|
||||
|
|
Loading…
Reference in New Issue
Block a user