Skip to content

Commit 113c33e

Browse files
author
mongkok
committed
Added tests for feature types
1 parent f6098b6 commit 113c33e

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

tests/types/test_feature.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,47 @@
11
from django.test import TestCase
22

3+
from graphene_django.types import DjangoObjectTypeOptions
4+
35
from graphql_geojson.types import feature as types
46

7+
from .. import models
8+
59

610
class FeatureTypeTests(TestCase):
711

8-
def test_ordered_fields(self):
12+
def test_update_ordered_fields(self):
913
ordered_fields = types.OrderedFields()
1014
ordered_fields.update(test=True)
1115

1216
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)

0 commit comments

Comments
 (0)