def test_to_representation(self): """ Check that to_representation raises a NotImplementedError """ test_serializer = serializers.BaseSerializer() self.assertRaises(NotImplementedError, test_serializer.to_representation, 'foo')
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})
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'})
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})
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': {}})
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'})
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'))