diff --git a/CHANGELOG.md b/CHANGELOG.md index 013775bc6..32e052bb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change log +- [#431](https://github.com/mobilityhouse/ocpp/issues/431) Attributes with 'v2x' are serialized as 'V2x', but should be serialized as 'V2X' - [#554](https://github.com/mobilityhouse/ocpp/issues/554) OCPP 2.0.1 Edition 2 Errata 2023-12 document added - [#548](https://github.com/mobilityhouse/ocpp/issues/548) OCPP 2.0.1 MessageInfoType attribute name correction - [#300](https://github.com/mobilityhouse/ocpp/issues/300) OCPP 2.0.1 add reference components and variables diff --git a/ocpp/charge_point.py b/ocpp/charge_point.py index c4a82d41c..997943de7 100644 --- a/ocpp/charge_point.py +++ b/ocpp/charge_point.py @@ -44,7 +44,7 @@ def camel_to_snake_case(data): def snake_to_camel_case(data): """ - Convert all keys of a all dictionaries inside given argument from + Convert all keys of all dictionaries inside given argument from snake_case to camelCase. Inspired by: https://stackoverflow.com/a/19053800/1073222 @@ -53,6 +53,7 @@ def snake_to_camel_case(data): camel_case_dict = {} for key, value in data.items(): key = key.replace("soc", "SoC") + key = key.replace("_v2x", "V2X") components = key.split("_") key = components[0] + "".join(x[:1].upper() + x[1:] for x in components[1:]) camel_case_dict[key] = snake_to_camel_case(value) diff --git a/tests/test_charge_point.py b/tests/test_charge_point.py index de505baad..e6b320ef0 100644 --- a/tests/test_charge_point.py +++ b/tests/test_charge_point.py @@ -65,6 +65,8 @@ def test_camel_to_snake_case(test_input, expected): [ ({"transaction_id": "74563478"}, {"transactionId": "74563478"}), ({"full_soc": 100}, {"fullSoC": 100}), + ({"ev_min_v2x_energy_request": 200}, {"evMinV2XEnergyRequest": 200}), + ({"v2x_charging_ctrlr": 200}, {"v2xChargingCtrlr": 200}), ], ) def test_snake_to_camel_case(test_input, expected):