mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-08 06:14:47 +03:00
Added test for MappingField
This commit is contained in:
parent
bef4408d10
commit
806b0f60cf
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user