Skip to content

Commit aa36ed5

Browse files
Add missing gateway result codes and add tests for it
The test verifies that all of the error codes defined in the currently used protobuf definition can be converted to the internal GateayResultCode enum (in case some of them are forgotten to be added here).
1 parent ee4e131 commit aa36ed5

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/test_gateway_result_code.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# flake8: noqa
2+
3+
import pytest
4+
5+
from wirepas_mesh_messaging.proto import ErrorCode
6+
from wirepas_mesh_messaging import GatewayResultCode
7+
8+
@pytest.mark.parametrize("protobuf_result_code", ErrorCode.items())
9+
def test_decoding_errors(protobuf_result_code):
10+
name, value = protobuf_result_code
11+
try:
12+
GatewayResultCode(value)
13+
except ValueError as e:
14+
raise ValueError(f"{name} is not defined in GatewayResultCode") from e
15+

wirepas_mesh_messaging/gateway_result_code.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@ class GatewayResultCode(enum.Enum):
5050
GW_RES_INVALID_MAX_HOP_COUNT = INVALID_MAX_HOP_COUNT
5151
GW_RES_SINK_OUT_OF_MEMORY = SINK_OUT_OF_MEMORY
5252
GW_RES_SINK_TIMEOUT = SINK_TIMEOUT
53+
GW_RES_INVALID_SCRATCHPAD_CHUNK_OFFSET = INVALID_SCRATCHPAD_CHUNK_OFFSET
54+
GW_RES_INVALID_SCRATCHPAD_CHUNK_SIZE = INVALID_SCRATCHPAD_CHUNK_SIZE

0 commit comments

Comments
 (0)