Permalink
Browse files

test that serializer works with subclasses

  • Loading branch information...
1 parent f924856 commit 6804c628621fb7152937559079d0ed1e2bc1ef65 @HonzaKral HonzaKral committed Oct 5, 2012
Showing with 22 additions and 0 deletions.
  1. +22 −0 test_ella/test_api/test_serialization.py
@@ -0,0 +1,22 @@
+from django.test import TestCase
+
+from ella.api import object_serializer, FULL
+from ella.core.models import Publishable
+from ella.articles.models import Article
+
+from nose import tools
+
+class TestObjectSerialization(TestCase):
+ def setUp(self):
+ super(TestObjectSerialization, self).setUp()
+ self.old_registry = object_serializer._registry.copy()
+ object_serializer.register(Publishable, lambda r, a: 'Publishable %s' % a.id)
+
+ def tearDown(self):
+ super(TestObjectSerialization, self).tearDown()
+ object_serializer._registry = self.old_registry
+
+ def test_article_is_properly_serialized(self):
+ art = Article(id=42)
+ tools.assert_equals('Publishable 42', object_serializer.serialize(None, art, FULL))
+

0 comments on commit 6804c62

Please sign in to comment.