mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 12:16:58 +03:00
Fixed argument getter in django filters tests
This commit is contained in:
parent
689db2c70e
commit
b4f7df3c9d
|
@ -35,12 +35,13 @@ class PetNode(DjangoNode):
|
|||
class Meta:
|
||||
model = Pet
|
||||
|
||||
schema = Schema()
|
||||
|
||||
def assert_arguments(field, *arguments):
|
||||
ignore = ('after', 'before', 'first', 'last', 'orderBy')
|
||||
actual = [
|
||||
name
|
||||
for name in field.arguments.arguments.keys()
|
||||
for name in schema.T(field.arguments)
|
||||
if name not in ignore and not name.startswith('_')
|
||||
]
|
||||
assert set(arguments) == set(actual), \
|
||||
|
@ -51,12 +52,12 @@ def assert_arguments(field, *arguments):
|
|||
|
||||
|
||||
def assert_orderable(field):
|
||||
assert 'orderBy' in field.arguments.arguments.keys(), \
|
||||
assert 'orderBy' in schema.T(field.arguments), \
|
||||
'Field cannot be ordered'
|
||||
|
||||
|
||||
def assert_not_orderable(field):
|
||||
assert 'orderBy' not in field.arguments.arguments.keys(), \
|
||||
assert 'orderBy' not in schema.T(field.arguments), \
|
||||
'Field can be ordered'
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import pytest
|
||||
from py.test import raises
|
||||
|
||||
import graphene
|
||||
|
@ -7,6 +8,9 @@ from graphene.contrib.django import DjangoNode, DjangoObjectType
|
|||
from .models import Article, Reporter
|
||||
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
def test_should_query_only_fields():
|
||||
with raises(Exception):
|
||||
class ReporterType(DjangoObjectType):
|
||||
|
|
|
@ -66,7 +66,7 @@ def get_filtering_args_from_filterset(filterset_class, type):
|
|||
|
||||
# Also add the 'order_by' field
|
||||
if filterset_class._meta.order_by:
|
||||
args[filterset_class.order_by_field] = Argument(String)
|
||||
args[filterset_class.order_by_field] = Argument(String())
|
||||
return args
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user