def test_under_to_camel_input_untouched_for_sequence(self):
     data = [
         {
             'first_input': 1
         },
         {
             'second_input': 2
         },
     ]
     reference_input = deepcopy(data)
     underscoreize(data)
     self.assertEqual(data, reference_input)
    def parse(self, stream, media_type=None, parser_context=None):
        parser_context = parser_context or {}
        encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)

        try:
            data = stream.read().decode(encoding)
            return underscoreize(json.loads(data), **self.json_underscoreize)
        except ValueError as exc:
            raise ParseError('JSON parse error - %s' % six.text_type(exc))
 def test_underscoreize_iterates_over_generator(self):
     data = self._camel_generator()
     output = [
         {
             'simple_is_better': 'than complex'
         },
         {
             'that_is': 'correct'
         },
     ]
     self.assertEqual(underscoreize(data), output)
 def test_camel_to_under_keys(self):
     data = {
         "twoWord": 1,
         "longKeyWithManyUnderscores": 2,
         "only1Key": 3,
         "onlyOneLetterA": 4,
         "bOnlyOneLetter": 5,
         "onlyCLetter": 6,
         "mix123123aAndLetters": 7,
     }
     output = {
         "two_word": 1,
         "long_key_with_many_underscores": 2,
         "only_1_key": 3,
         "only_one_letter_a": 4,
         "b_only_one_letter": 5,
         "only_c_letter": 6,
         "mix_123123a_and_letters": 7
     }
     self.assertEqual(underscoreize(data), output)
 def test_non_string_key(self):
     data = {1: "test"}
     self.assertEqual(underscoreize(camelize(data)), data)
 def test_camel_to_under_keys_with_no_underscore_before_number(self):
     data = {'noUnderscoreBefore123': 1}
     output = {'no_underscore_before123': 1}
     options = {'no_underscore_before_number': True}
     self.assertEqual(underscoreize(data, **options), output)
 def test_non_string_key(self):
     data = {1: "test"}
     assert underscoreize(camelize(data)) == data