mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-25 19:14:11 +03:00
Fixed tests
This commit is contained in:
parent
b8f9fec674
commit
1a728e4e88
|
@ -114,7 +114,10 @@ def convert_onetoone_field_to_djangomodel(field, registry=None):
|
|||
if not _type:
|
||||
return
|
||||
|
||||
return Field(_type, required=not field.null)
|
||||
# We do this for a bug in Django 1.8, where null attr
|
||||
# is not available in the OneToOneRel instance
|
||||
null = getattr(field, 'null', True)
|
||||
return Field(_type, required=not null)
|
||||
|
||||
return Dynamic(dynamic_type)
|
||||
|
||||
|
@ -149,7 +152,7 @@ def convert_relatedfield_to_djangomodel(field, registry=None):
|
|||
return
|
||||
|
||||
if isinstance(field.field, models.OneToOneField):
|
||||
return Field(_type, required=not field.field.null)
|
||||
return Field(_type)
|
||||
|
||||
if is_node(_type):
|
||||
return get_connection_field(_type)
|
||||
|
|
|
@ -20,11 +20,17 @@ from .models import Article, Film, FilmDetails, Reporter
|
|||
|
||||
|
||||
def assert_conversion(django_field, graphene_field, *args, **kwargs):
|
||||
field = django_field(help_text='Custom Help Text', *args, **kwargs)
|
||||
field = django_field(help_text='Custom Help Text', null=True, *args, **kwargs)
|
||||
graphene_type = convert_django_field(field)
|
||||
assert isinstance(graphene_type, graphene_field)
|
||||
field = graphene_type.Field()
|
||||
assert field.description == 'Custom Help Text'
|
||||
nonnull_field = django_field(null=False, *args, **kwargs)
|
||||
if not nonnull_field.null:
|
||||
nonnull_graphene_type = convert_django_field(nonnull_field)
|
||||
nonnull_field = nonnull_graphene_type.Field()
|
||||
assert isinstance(nonnull_field.type, graphene.NonNull)
|
||||
return nonnull_field
|
||||
return field
|
||||
|
||||
|
||||
|
@ -226,8 +232,7 @@ def test_should_onetoone_reverse_convert_model():
|
|||
assert isinstance(graphene_field, graphene.Dynamic)
|
||||
dynamic_field = graphene_field.get_type()
|
||||
assert isinstance(dynamic_field, graphene.Field)
|
||||
assert isinstance(dynamic_field.type, graphene.NonNull)
|
||||
assert dynamic_field.of_type.type == A
|
||||
assert dynamic_field.type == A
|
||||
|
||||
|
||||
@pytest.mark.skipif(ArrayField is MissingType,
|
||||
|
|
Loading…
Reference in New Issue
Block a user