From 38af6107b5fb26e2dffdeeadad80df70e256a5f3 Mon Sep 17 00:00:00 2001 From: Jacob Magnusson Date: Sat, 3 Nov 2012 00:32:08 +0100 Subject: [PATCH] Added test for ModelSerializer Meta fields returning as expected --- rest_framework/tests/serializer.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rest_framework/tests/serializer.py b/rest_framework/tests/serializer.py index 5d46ff68f..3fd490644 100644 --- a/rest_framework/tests/serializer.py +++ b/rest_framework/tests/serializer.py @@ -105,6 +105,14 @@ class BasicTests(TestCase): self.assertEquals(serializer.object, expected) self.assertTrue(serializer.object is expected) self.assertEquals(serializer.data['sub_comment'], 'And Merry Christmas!') + + def test_model_fields_as_expected(self): + """ Make sure that the fields returned are the same as defined + in the Meta data + """ + serializer = PersonSerializer(instance=self.person) + self.assertEquals(set(serializer.data.keys()), + set(['name', 'age', 'info'])) def test_field_with_dictionary(self): """ Make sure that dictionaries from fields are left intact