File tree Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change 1
1
from django .test import TestCase
2
2
3
+ from graphene_django .types import DjangoObjectTypeOptions
4
+
3
5
from graphql_geojson .types import feature as types
4
6
7
+ from .. import models
8
+
5
9
6
10
class FeatureTypeTests (TestCase ):
7
11
8
- def test_ordered_fields (self ):
12
+ def test_update_ordered_fields (self ):
9
13
ordered_fields = types .OrderedFields ()
10
14
ordered_fields .update (test = True )
11
15
12
16
self .assertTrue (ordered_fields ['test' ])
17
+
18
+ def test_geojson_type_custom_meta (self ):
19
+
20
+ class GeoJSONType (types .GeoJSONType ):
21
+
22
+ class Meta :
23
+ abstract = True
24
+
25
+ @classmethod
26
+ def __init_subclass_with_meta__ (cls , ** options ):
27
+ options .setdefault ('_meta' , DjangoObjectTypeOptions (cls ))
28
+ super ().__init_subclass_with_meta__ (** options )
29
+
30
+ class PlaceType (GeoJSONType ):
31
+
32
+ class Meta :
33
+ model = models .Place
34
+ geojson_field = 'location'
35
+
36
+ self .assertIsInstance (PlaceType ._meta , DjangoObjectTypeOptions )
37
+
38
+ def test_geojson_type_options_missing_pk (self ):
39
+
40
+ class PlaceType (types .GeoJSONType ):
41
+
42
+ class Meta :
43
+ model = models .Place
44
+ geojson_field = 'location'
45
+ only_fields = ['location' ]
46
+
47
+ self .assertNotIn ('id' , PlaceType ()._meta .fields )
You can’t perform that action at this time.
0 commit comments