mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-12 09:12:18 +03:00
Add test for max_limit.
This commit is contained in:
parent
14ae2f44d3
commit
201fd19451
|
@ -1084,6 +1084,48 @@ def test_should_resolve_get_queryset_connectionfields():
|
|||
assert result.data == expected
|
||||
|
||||
|
||||
REPORTERS = [
|
||||
dict(
|
||||
first_name=f"First {i}",
|
||||
last_name=f"Last {i}",
|
||||
email=f"johndoe+{i}@example.com",
|
||||
a_choice=1,
|
||||
)
|
||||
for i in range(6)
|
||||
]
|
||||
|
||||
|
||||
def test_should_return_max_limit(graphene_settings):
|
||||
graphene_settings.RELAY_CONNECTION_MAX_LIMIT = 4
|
||||
reporters = [Reporter(**kwargs) for kwargs in REPORTERS]
|
||||
Reporter.objects.bulk_create(reporters)
|
||||
|
||||
class ReporterType(DjangoObjectType):
|
||||
class Meta:
|
||||
model = Reporter
|
||||
interfaces = (Node,)
|
||||
|
||||
class Query(graphene.ObjectType):
|
||||
all_reporters = DjangoConnectionField(ReporterType)
|
||||
|
||||
schema = graphene.Schema(query=Query)
|
||||
query = """
|
||||
query AllReporters {
|
||||
allReporters {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
result = schema.execute(query)
|
||||
assert not result.errors
|
||||
assert len(result.data["allReporters"]["edges"]) == 4
|
||||
|
||||
|
||||
def test_should_preserve_prefetch_related(django_assert_num_queries):
|
||||
class ReporterType(DjangoObjectType):
|
||||
class Meta:
|
||||
|
|
Loading…
Reference in New Issue
Block a user