diff --git a/ocpp/exceptions.py b/ocpp/exceptions.py index 6c570425f..e2e331cc4 100644 --- a/ocpp/exceptions.py +++ b/ocpp/exceptions.py @@ -35,14 +35,14 @@ def __str__(self): class NotImplementedError(OCPPError): code = "NotImplemented" - default_description = "Requested Action is not known by receiver" + default_description = ( + "Request Action is recognized but not supported by the receiver" + ) class NotSupportedError(OCPPError): code = "NotSupported" - default_description = ( - "Request Action is recognized but not supported by " "the receiver" - ) + default_description = "Requested Action is not known by receiver" class InternalError(OCPPError): diff --git a/tests/v16/conftest.py b/tests/v16/conftest.py index d747bf420..41c4eb290 100644 --- a/tests/v16/conftest.py +++ b/tests/v16/conftest.py @@ -16,6 +16,9 @@ def heartbeat_call(): return Call(unique_id=1, action=Action.Heartbeat, payload={}).to_json() +@pytest.fixture +def notsupported_call(): + return Call(unique_id=1, action="InvalidAction", payload={}).to_json() @pytest.fixture def boot_notification_call(): diff --git a/tests/v16/test_v16_charge_point.py b/tests/v16/test_v16_charge_point.py index 6e002ffe8..d08a6a408 100644 --- a/tests/v16/test_v16_charge_point.py +++ b/tests/v16/test_v16_charge_point.py @@ -125,13 +125,36 @@ async def test_route_message_with_no_route(base_central_system, heartbeat_call): 4, 1, "NotImplemented", - "Requested Action is not known by receiver", + "Request Action is recognized but not supported by the receiver", {"cause": "No handler for Heartbeat registered."}, ], separators=(",", ":"), ) ) +@pytest.mark.asyncio +async def test_route_message_not_supported(base_central_system, notsupported_call): + """ + Test that a CALLERROR is sent back, reporting that it is + not supported by OCPP version. + + """ + # Empty the route map + base_central_system.route_map = {} + + await base_central_system.route_message(notsupported_call) + base_central_system._connection.send.assert_called_once_with( + json.dumps( + [ + 4, + 1, + "NotSupported", + "Requested Action is not known by receiver", + {"cause": "InvalidAction not supported by OCPP1.6."}, + ], + separators=(",", ":"), + ) + ) @pytest.mark.asyncio async def test_send_call_with_timeout(connection): diff --git a/tests/v20/test_v20_charge_point.py b/tests/v20/test_v20_charge_point.py index 56c49a9ec..bb0a04aa2 100644 --- a/tests/v20/test_v20_charge_point.py +++ b/tests/v20/test_v20_charge_point.py @@ -77,7 +77,7 @@ async def test_route_message_with_no_route(base_central_system, heartbeat_call): 4, 1, "NotImplemented", - "Requested Action is not known by receiver", + "Request Action is recognized but not supported by the receiver", {"cause": "No handler for Heartbeat registered."}, ], separators=(",", ":"), diff --git a/tests/v201/test_v201_charge_point.py b/tests/v201/test_v201_charge_point.py index eacc22d7a..ddbd33808 100644 --- a/tests/v201/test_v201_charge_point.py +++ b/tests/v201/test_v201_charge_point.py @@ -77,7 +77,7 @@ async def test_route_message_with_no_route(base_central_system, heartbeat_call): 4, 1, "NotImplemented", - "Requested Action is not known by receiver", + "Request Action is recognized but not supported by the receiver", {"cause": "No handler for Heartbeat registered."}, ], separators=(",", ":"),