1
1
import pytest
2
2
from django .db import models
3
3
from django .utils .translation import ugettext_lazy as _
4
- from django .contrib .postgres .fields import ArrayField , HStoreField
5
-
6
4
from py .test import raises
7
5
8
6
import graphene
9
7
from graphene .relay import ConnectionField , Node
10
8
from graphene .types .datetime import DateTime , Time
11
9
from graphene .types .json import JSONString
12
10
13
- from ..compat import JSONField , MissingType
11
+ from ..compat import JSONField , RelatedObject
14
12
from ..converter import convert_django_field , convert_django_field_with_choices
15
13
from ..registry import Registry
16
14
from ..types import DjangoObjectType
@@ -264,13 +262,17 @@ class Meta:
264
262
assert dynamic_field .type == A
265
263
266
264
265
+ @pytest .mark .skipif (ArrayField is MissingType ,
266
+ reason = "ArrayField should exist" )
267
267
def test_should_postgres_array_convert_list ():
268
268
field = assert_conversion (ArrayField , graphene .List , models .CharField (max_length = 100 ))
269
269
assert isinstance (field .type , graphene .NonNull )
270
270
assert isinstance (field .type .of_type , graphene .List )
271
271
assert field .type .of_type .of_type == graphene .String
272
272
273
273
274
+ @pytest .mark .skipif (ArrayField is MissingType ,
275
+ reason = "ArrayField should exist" )
274
276
def test_should_postgres_array_multiple_convert_list ():
275
277
field = assert_conversion (ArrayField , graphene .List , ArrayField (models .CharField (max_length = 100 )))
276
278
assert isinstance (field .type , graphene .NonNull )
@@ -279,6 +281,8 @@ def test_should_postgres_array_multiple_convert_list():
279
281
assert field .type .of_type .of_type .of_type == graphene .String
280
282
281
283
284
+ @pytest .mark .skipif (HStoreField is MissingType ,
285
+ reason = "HStoreField should exist" )
282
286
def test_should_postgres_hstore_convert_string ():
283
287
assert_conversion (HStoreField , JSONString )
284
288
@@ -289,6 +293,8 @@ def test_should_postgres_json_convert_string():
289
293
assert_conversion (JSONField , JSONString )
290
294
291
295
296
+ @pytest .mark .skipif (RangeField is MissingType ,
297
+ reason = "RangeField should exist" )
292
298
def test_should_postgres_range_convert_list ():
293
299
from django .contrib .postgres .fields import IntegerRangeField
294
300
field = assert_conversion (IntegerRangeField , graphene .List )
0 commit comments