File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
djangorestframework_camel_case Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,15 @@ def camelize(data):
16
16
new_key = re .sub (r"[a-z]_[a-z]" , underscoreToCamel , key )
17
17
new_dict [new_key ] = camelize (value )
18
18
return new_dict
19
- if isinstance (data , ( list , tuple ) ):
19
+ if isinstance (data , list ):
20
20
for i in range (len (data )):
21
21
data [i ] = camelize (data [i ])
22
22
return data
23
+ if isinstance (data , tuple ):
24
+ camelized_data = []
25
+ for i in range (len (data )):
26
+ camelized_data .append (camelize (data [i ]))
27
+ return tuple (camelized_data )
23
28
return data
24
29
25
30
Original file line number Diff line number Diff line change 7
7
8
8
9
9
class UnderscoreToCamelTestCase (TestCase ):
10
+
10
11
def test_under_to_camel (self ):
11
12
input = {
12
13
"title_display" : 1
@@ -16,6 +17,14 @@ def test_under_to_camel(self):
16
17
}
17
18
self .assertEqual (camelize (input ), output )
18
19
20
+ def test_tuples (self ):
21
+ input = {
22
+ "multiple_values" : (1 , 2 )
23
+ }
24
+ output = {
25
+ "multipleValues" : (1 , 2 )
26
+ }
27
+ self .assertEqual (camelize (input ), output )
19
28
20
29
class CamelToUnderscoreTestCase (TestCase ):
21
30
def test_under_to_camel (self ):
You can’t perform that action at this time.
0 commit comments