Example #1
0
 def test_to_representation(self):
     """
     Check that to_representation raises a NotImplementedError
     """
     test_serializer = serializers.BaseSerializer()
     self.assertRaises(NotImplementedError,
                       test_serializer.to_representation, 'foo')
Example #2
0
 def test__mask_field_multiple_value_none(self):
     """
     Test field masking with a multiple accessors
     """
     serializer = serializers.BaseSerializer('foo')
     representation = {'foo': 'bar', 'baz': None}
     serializer._mask_field(['baz', 'quux'], representation)
     self.assertDictEqual(representation, {'foo': 'bar', 'baz': None})
Example #3
0
 def test__mask_missing_field(self):
     """
     Test with a single accessor
     """
     serializer = serializers.BaseSerializer('foo')
     representation = {'foo': 'bar'}
     serializer._mask_field(['baz'], representation)
     self.assertDictEqual(representation, {'foo': 'bar'})
Example #4
0
 def test__remove_excluded_multiple_value_none(self):
     """
     Test with multiple accessors
     """
     serializer = serializers.BaseSerializer('foo')
     representation = {'foo': 'bar', 'baz': None}
     serializer._remove_excluded(['baz', 'quux'], representation)
     self.assertDictEqual(representation, {'foo': 'bar', 'baz': None})
Example #5
0
 def test__remove_excluded_multiple_missing_inner_field(self):
     """
     Test with multiple accessors
     """
     serializer = serializers.BaseSerializer('foo')
     representation = {'foo': 'bar', 'baz': {}}
     serializer._remove_excluded(['baz', 'quux'], representation)
     self.assertDictEqual(representation, {'foo': 'bar', 'baz': {}})
Example #6
0
 def test__remove_excluded(self):
     """
     Test with a single accessor
     """
     serializer = serializers.BaseSerializer('foo')
     representation = {'foo': 'bar', 'baz': 'quux'}
     serializer._remove_excluded(['baz'], representation)
     self.assertDictEqual(representation, {'foo': 'bar'})
Example #7
0
 def test_get_href(self):
     """
     Check that get_href returns None by default
     """
     test_serializer = serializers.BaseSerializer()
     self.assertRaises(NotImplementedError, test_serializer.get_href('foo'))