mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-27 03:54:01 +03:00
Made suggested cleanups. Refs #121.
This commit is contained in:
parent
e8ddbf435c
commit
c995ab397c
|
@ -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})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user