forked from django-json-api/django-rest-framework-json-api
- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_utils.py
31 lines (24 loc) · 882 Bytes
/
test_utils.py
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
29
30
31
"""
Test rest_framework_json_api's utils functions.
"""
fromrest_framework_json_apiimportutils
from ..serializersimportEntrySerializer
from ..testsimportTestBase
classGetRelatedResourceTests(TestBase):
"""
Ensure the `get_related_resource_type` function returns correct types.
"""
deftest_reverse_relation(self):
"""
Ensure reverse foreign keys have their types identified correctly.
"""
serializer=EntrySerializer()
field=serializer.fields['comments']
self.assertEqual(utils.get_related_resource_type(field), 'comments')
deftest_m2m_relation(self):
"""
Ensure m2ms have their types identified correctly.
"""
serializer=EntrySerializer()
field=serializer.fields['authors']
self.assertEqual(utils.get_related_resource_type(field), 'authors')