forked from dvndrsn/graphql-python-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
28 lines (19 loc) · 931 Bytes
/
test_utils.py
File metadata and controls
28 lines (19 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from django.test import TestCase
import graphene
from api.utils import to_global_id, from_global_id, GlobalID
class TestGlobalId(TestCase):
def test_to_global_id__can_be_decoded_from_type_name(self):
class TypeWithGlobalIDAndName(graphene.ObjectType):
class Meta:
interfaces = (graphene.Node, )
name = 'WithGlobalID'
encoded = to_global_id(TypeWithGlobalIDAndName, 2)
decoded = from_global_id(encoded)
self.assertEqual(decoded, GlobalID('WithGlobalID', 2))
def test_to_global_id__can_be_decoded_from_default_name(self):
class TypeWithGlobalIDWithoutName(graphene.ObjectType):
class Meta:
interfaces = (graphene.Node, )
encoded = to_global_id(TypeWithGlobalIDWithoutName, 3)
decoded = from_global_id(encoded)
self.assertEqual(decoded, GlobalID('TypeWithGlobalIDWithoutName', 3))