File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,7 @@ def snake_to_camel(name: str) -> str:
88
99
1010def snake_to_camel_keys (d : dict ) -> dict :
11- return {snake_to_camel (k ): v for k , v in d .items ()}
11+ return {
12+ snake_to_camel (k ): v if type (v ) is not dict else snake_to_camel_keys (v )
13+ for k , v in d .items ()
14+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ def test_is_successful_status_code_false():
1212def test_snake_to_camel ():
1313 assert helpers .snake_to_camel ("snake_to_camel" ) == "snakeToCamel"
1414 assert helpers .snake_to_camel ("wallet_address" ) == "walletAddress"
15- assert helpers .snake_to_camel ("contract_address " ) == "contractAddress"
15+ assert helpers .snake_to_camel ("contractAddress " ) == "contractAddress"
1616 assert helpers .snake_to_camel ("token_ids" ) == "tokenIds"
1717
1818
@@ -22,3 +22,26 @@ def test_snake_to_camel_keys():
2222 "snakeToCamel" : "snake_to_camel" ,
2323 "walletAddress" : "wallet_address" ,
2424 }
25+
26+
27+ def test_snake_to_camel_keys_nested ():
28+ d = {
29+ "snake_to_camel" : "snake_to_camel" ,
30+ "walletAddress" : "wallet_address" ,
31+ "nested" : {
32+ "nest_one" : "value" ,
33+ "nest_two" : {
34+ "nest_three" : "value" ,
35+ },
36+ },
37+ }
38+ assert helpers .snake_to_camel_keys (d ) == {
39+ "snakeToCamel" : "snake_to_camel" ,
40+ "walletAddress" : "wallet_address" ,
41+ "nested" : {
42+ "nestOne" : "value" ,
43+ "nestTwo" : {
44+ "nestThree" : "value" ,
45+ },
46+ },
47+ }
You can’t perform that action at this time.
0 commit comments