Add thorough tests for NamespacedSerializer
This commit is contained in:
parent
2ab8bd241b
commit
b347055bd1
18
api/tests.py
18
api/tests.py
@ -6,7 +6,7 @@ Test cases for API calls
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.test import TestCase
|
from django.test import TestCase, RequestFactory
|
||||||
from django_webtest import WebTest
|
from django_webtest import WebTest
|
||||||
|
|
||||||
import json
|
import json
|
||||||
@ -48,6 +48,22 @@ class TestNamespacedSerializer(TestCase):
|
|||||||
with self.assertRaises(ImproperlyConfigured):
|
with self.assertRaises(ImproperlyConfigured):
|
||||||
serializer = EmptyNamespacedSerializer()
|
serializer = EmptyNamespacedSerializer()
|
||||||
|
|
||||||
|
def test_namespacing(self):
|
||||||
|
class MySerializer(NamespacedSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Competence
|
||||||
|
fields = ('url',)
|
||||||
|
url_namespace = 'api'
|
||||||
|
|
||||||
|
competence = Competence.objects.create(
|
||||||
|
added_by=User.objects.create())
|
||||||
|
serializer = MySerializer(competence,
|
||||||
|
context={
|
||||||
|
'request': RequestFactory().get('/')
|
||||||
|
})
|
||||||
|
|
||||||
|
self.assertIsNotNone(serializer.data['url'])
|
||||||
|
|
||||||
class DuckClassTest(WebTest):
|
class DuckClassTest(WebTest):
|
||||||
"""
|
"""
|
||||||
Test case for duck related API calls
|
Test case for duck related API calls
|
||||||
|
Loading…
Reference in New Issue
Block a user