Skip to content

Commit 0596fe2

Browse files
Fix camel_to_snake_case for "v2x" (#594)
see issue mobilityhouse/ocpp#591
1 parent 91c21ea commit 0596fe2

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- [#557](https://github.com/mobilityhouse/ocpp/issues/557) OCPP 2.0.1 Wrong data type in CostUpdated total_cost
33
- [#564](https://github.com/mobilityhouse/ocpp/issues/564) Add support For Python 3.11 and 3.12
44
- [#583](https://github.com/mobilityhouse/ocpp/issues/583) OCPP v1.6/v2.0.1 deprecate dataclasses from calls and call results with the suffix 'Payload'
5+
- [#591](https://github.com/mobilityhouse/ocpp/issues/591) Camel_to_snake_case doesn't handle v2x correctly
56
- [#593](https://github.com/mobilityhouse/ocpp/issues/593) Update tests to use Call and CallResult without the suffix Payload
67

78
## 0.26.0 (2024-01-17)

ocpp/charge_point.py

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def camel_to_snake_case(data):
2525
if isinstance(data, dict):
2626
snake_case_dict = {}
2727
for key, value in data.items():
28+
key = key.replace("V2X", "_v2x")
2829
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", key)
2930
key = re.sub("([a-z0-9])([A-Z])(?=\\S)", r"\1_\2", s1).lower()
3031

tests/test_charge_point.py

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def heartbeat(self, **kwargs):
5252
[
5353
({"transactionId": "74563478"}, {"transaction_id": "74563478"}),
5454
({"fullSoC": 100}, {"full_soc": 100}),
55+
({"evMinV2XEnergyRequest": 200}, {"ev_min_v2x_energy_request": 200}),
56+
({"v2xChargingCtrlr": 200}, {"v2x_charging_ctrlr": 200}),
5557
],
5658
)
5759
def test_camel_to_snake_case(test_input, expected):

0 commit comments

Comments
 (0)