Made suggested cleanups. Refs #121.

This commit is contained in:
Tom Christie 2012-01-11 14:56:12 +00:00
parent e8ddbf435c
commit c995ab397c

View File

@ -120,13 +120,17 @@ class TestFieldNesting(TestCase):
self.assertEqual(SerializerM2().serialize(self.m2), {'field': {'field1': u'foo'}}) self.assertEqual(SerializerM2().serialize(self.m2), {'field': {'field1': u'foo'}})
self.assertEqual(SerializerM3().serialize(self.m3), {'field': {'field2': u'bar'}}) self.assertEqual(SerializerM3().serialize(self.m3), {'field': {'field2': u'bar'}})
def test_serializer_unvalid_hook_method(self): def test_serializer_overridden_hook_method(self):
""" """
Test serializing a model instance with an unvalid hook method on the serializer. Test serializing a model instance which overrides a class method on the
serializer. Checks for correct behaviour in odd edge case.
""" """
class SerializerM2(Serializer): class SerializerM2(Serializer):
fields = ('unvalid_hook', ) fields = ('overridden', )
def unvalid_hook(self):
return def overridden(self):
self.m2.unvalid_hook = 'bla' return False
self.assertEqual(SerializerM2().serialize_model(self.m2), {'unvalid_hook': 'bla'})
self.m2.overridden = True
self.assertEqual(SerializerM2().serialize_model(self.m2),
{'overridden': True})