From f8031e6d2d6a7a9636ed9970f0cba323d5a50430 Mon Sep 17 00:00:00 2001 From: Patrick Roelke Date: Wed, 11 May 2022 17:31:37 +0200 Subject: [PATCH] Handle responder_url edge case --- ocpp/charge_point.py | 7 ++++++- tests/test_charge_point.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ocpp/charge_point.py b/ocpp/charge_point.py index 2c2ac270e..0ff784f4d 100644 --- a/ocpp/charge_point.py +++ b/ocpp/charge_point.py @@ -53,7 +53,12 @@ def snake_to_camel_case(data): if isinstance(data, dict): camel_case_dict = {} for key, value in data.items(): - key = key.replace('soc', 'SoC') + # These are edge cases in the 2.0.1 spec that don't get handled + # well + if 'soc' in key: + key = key.replace('soc', 'SoC') + elif 'responder_url' in key: + key = key.replace('url', 'URL') components = key.split("_") key = components[0] + "".join( x[:1].upper() + x[1:] for x in components[1:]) diff --git a/tests/test_charge_point.py b/tests/test_charge_point.py index c966d4175..3cb1b856e 100644 --- a/tests/test_charge_point.py +++ b/tests/test_charge_point.py @@ -63,6 +63,7 @@ def test_camel_to_snake_case(test_input, expected): [ ({"transaction_id": "74563478"}, {"transactionId": "74563478"}), ({"full_soc": 100}, {"fullSoC": 100}), + ({"responder_url": "foo.com"}, {"responderURL": "foo.com"}) ], ) def test_snake_to_camel_case(test_input, expected):