diff --git a/ocpp/charge_point.py b/ocpp/charge_point.py index 7046cada5..601871488 100644 --- a/ocpp/charge_point.py +++ b/ocpp/charge_point.py @@ -25,8 +25,7 @@ def camel_to_snake_case(data): if isinstance(data, dict): snake_case_dict = {} for key, value in data.items(): - key = key.replace("ocppCSMS", "ocpp_csms") - key = key.replace("V2X", "_v2x") + key = key.replace("ocppCSMSURL", "ocpp_csms_url") key = key.replace("V2X", "_v2x").replace("V2G", "_v2g") s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", key) key = re.sub("([a-z0-9])([A-Z])(?=\\S)", r"\1_\2", s1).lower() @@ -57,7 +56,10 @@ def snake_to_camel_case(data): for key, value in data.items(): key = key.replace("soc", "SoC") key = key.replace("_v2x", "V2X") - key = key.replace("ocpp_csms", "ocppCSMS") + # The spec uses inconsent casing for "csms" and "url". + # E.g. "OcppCsmsUrl" vs "ResponderURL" and "CSMSRootCertificate" + key = key.replace("ocpp_csms_url", "ocppCsmsUrl") + key = key.replace("csms", "CSMS") key = key.replace("_url", "URL") key = key.replace("soc", "SoC").replace("_SoCket", "Socket") key = key.replace("_v2x", "V2X") diff --git a/tests/test_charge_point.py b/tests/test_charge_point.py index b1ab1412b..00571f9fd 100644 --- a/tests/test_charge_point.py +++ b/tests/test_charge_point.py @@ -68,6 +68,7 @@ def heartbeat(self, **kwargs): ({"responderURL": "foo.com"}, {"responder_url": "foo.com"}), ({"url": "foo.com"}, {"url": "foo.com"}), ({"ocppCSMSURL": "foo.com"}, {"ocpp_csms_url": "foo.com"}), + ({"CSMSRootCertificate": "foo.com"}, {"csms_root_certificate": "foo.com"}), ({"InvalidURL": "foo.com"}, {"invalid_url": "foo.com"}), ({"evMinV2XEnergyRequest": 200}, {"ev_min_v2x_energy_request": 200}), ({"v2xChargingCtrlr": 200}, {"v2x_charging_ctrlr": 200}), @@ -94,7 +95,8 @@ def test_camel_to_snake_case(test_input, expected): ({"v2x_charging_ctrlr": 200}, {"v2xChargingCtrlr": 200}), ({"responder_url": "foo.com"}, {"responderURL": "foo.com"}), ({"url": "foo.com"}, {"url": "foo.com"}), - ({"ocpp_csms_url": "foo.com"}, {"ocppCSMSURL": "foo.com"}), + ({"ocpp_csms_url": "foo.com"}, {"ocppCsmsUrl": "foo.com"}), + ({"csms_root_certificate": "foo.com"}, {"CSMSRootCertificate": "foo.com"}), ({"invalid_url": "foo.com"}, {"invalidURL": "foo.com"}), ({"web_socket_ping_interval": 200}, {"webSocketPingInterval": 200}), ({"sign_v2g_certificate": 200}, {"signV2GCertificate": 200}),