def test_converts_nested_values_one_level_deep(self):
     actual_dict = ConvertValuesToList()
     actual_dict.update({
         'one': {
             'three': 'another one'
         },
         'two': ['me too']
     })
     expected = {'one': [{'three': 'another one'}], 'two': ['me too']}
     self.assertEqual(expected, dict(actual_dict))
Esempio n. 2
0
 def _build_signature_dict_for_content_type(self, headers):
     content_type = headers.get("Content-Type")
     if content_type and content_type in ["application/json", "application/vnd.api+json"]:
         encoding_func = self.content_type_encodings.get(content_type, default_encoding)
         return encoding_func(self.raw_data)
     if self.raw_data:
         multi_dict = ConvertValuesToList()
         if type(self.raw_data) == str:
             multi_dict.update(json.loads(self.raw_data))
         else:
             multi_dict.update(self.raw_data)
         return dict(multi_dict)
     return {}
 def test_does_not_wrap_list(self):
     actual_list = ConvertValuesToList()
     with self.assertRaises(ValueError):
         actual_list.update(['list'])
 def test_converts_does_not_wrap_list_values_in_lists(self):
     actual_dict = ConvertValuesToList()
     actual_dict.update({'one': ['leave me alone'], 'two': ['me too']})
     expected = {'one': ['leave me alone'], 'two': ['me too']}
     self.assertEqual(expected, dict(actual_dict))
 def test_wraps_basic_dictionary_values(self):
     actual_dict = ConvertValuesToList()
     actual_dict.update({'one': 'zebra', 'two': 'monkey'})
     expected = {'one': ['zebra'], 'two': ['monkey']}
     self.assertEqual(expected, dict(actual_dict))
 def test_converts_integers_to_strings(self):
     actual_dict = ConvertValuesToList()
     actual_dict.update({'one': 1, 'two': 2})
     expected = {'one': ['1'], 'two': ['2']}
     self.assertEqual(expected, dict(actual_dict))
 def test_does_not_wrap_list(self):
     actual_list = ConvertValuesToList()
     with self.assertRaises(ValueError):
         actual_list.update(['list'])
 def test_converts_nested_values_one_level_deep(self):
     actual_dict = ConvertValuesToList()
     actual_dict.update({'one': {'three': 'another one'}, 'two': ['me too']})
     expected = {'one': [{'three': 'another one'}], 'two': ['me too']}
     self.assertEqual(expected, dict(actual_dict))
 def test_converts_does_not_wrap_list_values_in_lists(self):
     actual_dict = ConvertValuesToList()
     actual_dict.update({'one': ['leave me alone'], 'two': ['me too']})
     expected = {'one': ['leave me alone'], 'two': ['me too']}
     self.assertEqual(expected, dict(actual_dict))
 def test_converts_integers_to_strings(self):
     actual_dict = ConvertValuesToList()
     actual_dict.update({'one': 1, 'two': 2})
     expected = {'one': ['1'], 'two': ['2']}
     self.assertEqual(expected, dict(actual_dict))
 def test_wraps_basic_dictionary_values(self):
     actual_dict = ConvertValuesToList()
     actual_dict.update({'one': 'zebra', 'two': 'monkey'})
     expected = {'one': ['zebra'], 'two': ['monkey']}
     self.assertEqual(expected, dict(actual_dict))