diff --git a/tests/test_fields.py b/tests/test_fields.py index 76e6d9d60..f4ef749aa 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1125,6 +1125,38 @@ class TestMultipleChoiceField(FieldValues): assert field.get_value(QueryDict({})) == rest_framework.fields.empty +# Mapping types... + +class TestMappingFieldWithIntKeys(FieldValues): + """ + Valid and invalid values for `MappingField`. + """ + valid_inputs = { + 1: 'one', + 2: 'two', + 'three': 3, + 'four': 4 + } + invalid_inputs = { + 5: ['"5" not found in "mapping" dict'], + 'abc': ['"abc" not found in "mapping" dict'] + } + outputs = { + 'one': 1, + 'two': 2, + 3: 'three', + 4: 'four' + } + field = serializers.MappingField( + mapping={ + 1: 'one', + 2: 'two', + 'three': 3, + 'four': 4 + } + ) + + # File serializers... class MockFile: