mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-11-04 09:57:41 +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:
 | 
					    class Meta:
 | 
				
			||||||
        model = Pet
 | 
					        model = Pet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					schema = Schema()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def assert_arguments(field, *arguments):
 | 
					def assert_arguments(field, *arguments):
 | 
				
			||||||
    ignore = ('after', 'before', 'first', 'last', 'orderBy')
 | 
					    ignore = ('after', 'before', 'first', 'last', 'orderBy')
 | 
				
			||||||
    actual = [
 | 
					    actual = [
 | 
				
			||||||
        name
 | 
					        name
 | 
				
			||||||
        for name in field.arguments.arguments.keys()
 | 
					        for name in schema.T(field.arguments)
 | 
				
			||||||
        if name not in ignore and not name.startswith('_')
 | 
					        if name not in ignore and not name.startswith('_')
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
    assert set(arguments) == set(actual), \
 | 
					    assert set(arguments) == set(actual), \
 | 
				
			||||||
| 
						 | 
					@ -51,12 +52,12 @@ def assert_arguments(field, *arguments):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def assert_orderable(field):
 | 
					def assert_orderable(field):
 | 
				
			||||||
    assert 'orderBy' in field.arguments.arguments.keys(), \
 | 
					    assert 'orderBy' in schema.T(field.arguments), \
 | 
				
			||||||
        'Field cannot be ordered'
 | 
					        'Field cannot be ordered'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def assert_not_orderable(field):
 | 
					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'
 | 
					        'Field can be ordered'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					import pytest
 | 
				
			||||||
from py.test import raises
 | 
					from py.test import raises
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import graphene
 | 
					import graphene
 | 
				
			||||||
| 
						 | 
					@ -7,6 +8,9 @@ from graphene.contrib.django import DjangoNode, DjangoObjectType
 | 
				
			||||||
from .models import Article, Reporter
 | 
					from .models import Article, Reporter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pytestmark = pytest.mark.django_db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_should_query_only_fields():
 | 
					def test_should_query_only_fields():
 | 
				
			||||||
    with raises(Exception):
 | 
					    with raises(Exception):
 | 
				
			||||||
        class ReporterType(DjangoObjectType):
 | 
					        class ReporterType(DjangoObjectType):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -66,7 +66,7 @@ def get_filtering_args_from_filterset(filterset_class, type):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Also add the 'order_by' field
 | 
					    # Also add the 'order_by' field
 | 
				
			||||||
    if filterset_class._meta.order_by:
 | 
					    if filterset_class._meta.order_by:
 | 
				
			||||||
        args[filterset_class.order_by_field] = Argument(String)
 | 
					        args[filterset_class.order_by_field] = Argument(String())
 | 
				
			||||||
    return args
 | 
					    return args
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user