11import pytest
22from django .db import models
33from django .utils .translation import ugettext_lazy as _
4- from django .contrib .postgres .fields import ArrayField , HStoreField
5-
64from py .test import raises
75
86import graphene
97from graphene .relay import ConnectionField , Node
108from graphene .types .datetime import DateTime , Time
119from graphene .types .json import JSONString
1210
13- from ..compat import JSONField , MissingType
11+ from ..compat import JSONField , RelatedObject
1412from ..converter import convert_django_field , convert_django_field_with_choices
1513from ..registry import Registry
1614from ..types import DjangoObjectType
@@ -264,13 +262,17 @@ class Meta:
264262 assert dynamic_field .type == A
265263
266264
265+ @pytest .mark .skipif (ArrayField is MissingType ,
266+ reason = "ArrayField should exist" )
267267def test_should_postgres_array_convert_list ():
268268 field = assert_conversion (ArrayField , graphene .List , models .CharField (max_length = 100 ))
269269 assert isinstance (field .type , graphene .NonNull )
270270 assert isinstance (field .type .of_type , graphene .List )
271271 assert field .type .of_type .of_type == graphene .String
272272
273273
274+ @pytest .mark .skipif (ArrayField is MissingType ,
275+ reason = "ArrayField should exist" )
274276def test_should_postgres_array_multiple_convert_list ():
275277 field = assert_conversion (ArrayField , graphene .List , ArrayField (models .CharField (max_length = 100 )))
276278 assert isinstance (field .type , graphene .NonNull )
@@ -279,6 +281,8 @@ def test_should_postgres_array_multiple_convert_list():
279281 assert field .type .of_type .of_type .of_type == graphene .String
280282
281283
284+ @pytest .mark .skipif (HStoreField is MissingType ,
285+ reason = "HStoreField should exist" )
282286def test_should_postgres_hstore_convert_string ():
283287 assert_conversion (HStoreField , JSONString )
284288
@@ -289,6 +293,8 @@ def test_should_postgres_json_convert_string():
289293 assert_conversion (JSONField , JSONString )
290294
291295
296+ @pytest .mark .skipif (RangeField is MissingType ,
297+ reason = "RangeField should exist" )
292298def test_should_postgres_range_convert_list ():
293299 from django .contrib .postgres .fields import IntegerRangeField
294300 field = assert_conversion (IntegerRangeField , graphene .List )
0 commit comments