We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c80b5cb commit 9d13e08Copy full SHA for 9d13e08
2 files changed
tests/adapters.py
@@ -38,3 +38,8 @@ class Meta(object):
38
first_name = adapter.Field(source='first')
39
last_name = adapter.Field(source='last')
40
birthday = adapter.Field(source='dob', required=False)
41
+
42
43
+class ListToDictAdapter(adapter.Adapter):
44
+ first_name = adapter.Field(source='0')
45
+ last_name = adapter.Field(source='2')
tests/test_adapter.py
@@ -70,3 +70,12 @@ def test_dict_to_dict(self):
70
'last_name': 'Phillips',
71
}
72
self.assertDictEqual(actual, expected)
73
74
+ def test_list_to_dict(self):
75
+ data = ['Paul', 'G.', 'Hickey']
76
+ actual = adapters.ListToDictAdapter().adapt(data)
77
+ expected = {
78
+ 'first_name': 'Paul',
79
+ 'last_name': 'Hickey',
80
+ }
81
+ self.assertDictEqual(actual, expected)
0 commit comments