Added test for MappingField

This commit is contained in:
Anton-Shutik 2015-07-01 14:43:35 +03:00
parent bef4408d10
commit 806b0f60cf

View File

@ -1125,6 +1125,38 @@ class TestMultipleChoiceField(FieldValues):
assert field.get_value(QueryDict({})) == rest_framework.fields.empty 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... # File serializers...
class MockFile: class MockFile: