def test_camel_to_under_input_untouched_for_sequence(self): data = [ { 'firstInput': 1 }, { 'secondInput': 2 }, ] reference_input = deepcopy(data) camelize(data) self.assertEqual(data, reference_input)
def test_translation(self): settings.configure(USE_I18N=True) app = get_wsgi_application() data = { "two_word": _('Example'), } output = { "twoWord": "Example", } assert camelize(data) == output
def test_camelize_iterates_over_generator(self): data = self._underscore_generator() output = [ { 'simpleIsBetter': 'than complex' }, { 'thatIs': 'correct' }, ] self.assertEqual(camelize(data), output)
def test_under_to_camel_keys(self): data = { "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, "no_underscore_before123": 8 } output = { "twoWord": 1, "longKeyWithManyUnderscores": 2, "only1Key": 3, "onlyOneLetterA": 4, "bOnlyOneLetter": 5, "onlyCLetter": 6, "mix123123aAndLetters": 7, "noUnderscoreBefore123": 8 } self.assertEqual(camelize(data), output)
def render(self, data, *args, **kwargs): return super(CamelCaseJSONRenderer, self).render(camelize(data), *args, **kwargs)
def test_non_string_key(self): data = {1: "test"} self.assertEqual(underscoreize(camelize(data)), data)
def test_tuples(self): data = {"multiple_values": (1, 2), "data": [1, 3, 4]} output = {"multipleValues": [1, 2], "data": [1, 3, 4]} self.assertEqual(camelize(data), output)
def test_tuples(self): data = {"multiple_values": (1, 2), "data": [1, 3, 4]} output = {"multipleValues": [1, 2], "data": [1, 3, 4]} assert camelize(data) == output
def test_non_string_key(self): data = {1: "test"} assert underscoreize(camelize(data)) == data