Skip to content

Commit

Permalink
Add extra test, align defs with spec
Browse files Browse the repository at this point in the history
  • Loading branch information
drc38 authored Oct 19, 2023
1 parent a12d2d5 commit dfa6b1f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
8 changes: 4 additions & 4 deletions ocpp/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions tests/v16/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
25 changes: 24 additions & 1 deletion tests/v16/test_v16_charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/v20/test_v20_charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=(",", ":"),
Expand Down
2 changes: 1 addition & 1 deletion tests/v201/test_v201_charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=(",", ":"),
Expand Down

0 comments on commit dfa6b1f

Please sign in to comment.