From 487b63375e305eafbe88ac78a0e85c4992fcb738 Mon Sep 17 00:00:00 2001 From: Jared Newell Date: Mon, 13 Nov 2023 14:12:28 +0100 Subject: [PATCH 1/3] snakecase SoC update + change log --- CHANGELOG.md | 2 +- ocpp/charge_point.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6cd7bf26..9786326f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change log - +- [#523](https://github.com/mobilityhouse/ocpp/issues/523) The serialisation of soc to SoC should not occur in camel case if it is existing at the beginning of a field - [#510](https://github.com/mobilityhouse/ocpp/issues/510) v2.0.1 UnitOfMeasureType - Enums missing and update docstring to allow use for variableCharacteristics - [#508](https://github.com/mobilityhouse/ocpp/issues/508) Exception - OccurrenceConstraintViolationError doc string correction diff --git a/ocpp/charge_point.py b/ocpp/charge_point.py index 5e31f3fe7..c5f8cbdcc 100644 --- a/ocpp/charge_point.py +++ b/ocpp/charge_point.py @@ -52,7 +52,7 @@ def snake_to_camel_case(data): if isinstance(data, dict): camel_case_dict = {} for key, value in data.items(): - key = key.replace("soc", "SoC") + key = key.replace("_soc", "SoC") 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) From 3a61da322b5c6d12267bf09ecbedadf605c7e288 Mon Sep 17 00:00:00 2001 From: Jared Newell Date: Wed, 15 Nov 2023 14:01:34 +0100 Subject: [PATCH 2/3] extended unit test --- tests/test_charge_point.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_charge_point.py b/tests/test_charge_point.py index de505baad..49891c14d 100644 --- a/tests/test_charge_point.py +++ b/tests/test_charge_point.py @@ -65,6 +65,7 @@ def test_camel_to_snake_case(test_input, expected): [ ({"transaction_id": "74563478"}, {"transactionId": "74563478"}), ({"full_soc": 100}, {"fullSoC": 100}), + ({"soc_limit_reached": 200}, {"socLimitReached": 200}), ], ) def test_snake_to_camel_case(test_input, expected): From 37281a0c6a23dabff63159e136dcc6047fe8395f Mon Sep 17 00:00:00 2001 From: Jared Newell Date: Tue, 13 Feb 2024 15:47:07 +0100 Subject: [PATCH 3/3] test extension --- ocpp/charge_point.py | 3 ++- tests/test_charge_point.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ocpp/charge_point.py b/ocpp/charge_point.py index c5f8cbdcc..cb3a317b4 100644 --- a/ocpp/charge_point.py +++ b/ocpp/charge_point.py @@ -52,7 +52,8 @@ def snake_to_camel_case(data): if isinstance(data, dict): camel_case_dict = {} for key, value in data.items(): - key = key.replace("_soc", "SoC") + key = key.replace("soc_limit_reached", "SOCLimitReached") + key = key.replace("soc", "SoC") 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 49891c14d..deeb62748 100644 --- a/tests/test_charge_point.py +++ b/tests/test_charge_point.py @@ -65,7 +65,7 @@ def test_camel_to_snake_case(test_input, expected): [ ({"transaction_id": "74563478"}, {"transactionId": "74563478"}), ({"full_soc": 100}, {"fullSoC": 100}), - ({"soc_limit_reached": 200}, {"socLimitReached": 200}), + ({"soc_limit_reached": 200}, {"SOCLimitReached": 200}), ], ) def test_snake_to_camel_case(test_input, expected):