diff --git a/pyoverkiz/enums/execution.py b/pyoverkiz/enums/execution.py index 073224e5..f5feb482 100644 --- a/pyoverkiz/enums/execution.py +++ b/pyoverkiz/enums/execution.py @@ -1,8 +1,12 @@ +import logging from enum import Enum, unique +_LOGGER = logging.getLogger(__name__) + @unique class ExecutionType(str, Enum): + UNKNOWN = "UNKNOWN" IMMEDIATE_EXECUTION = "Immediate execution" DELAYED_EXECUTION = "Delayed execution" TECHNICAL_EXECUTION = "Technical execution" @@ -10,9 +14,15 @@ class ExecutionType(str, Enum): RAW_TRIGGER_SERVER = "Raw trigger (Server)" RAW_TRIGGER_GATEWAY = "Raw trigger (Gateway)" + @classmethod + def _missing_(cls, value): # type: ignore + _LOGGER.warning(f"Unsupported value {value} has been returned for {cls}") + return cls.UNKNOWN + @unique class ExecutionState(str, Enum): + UNKNOWN = "UNKNOWN" INITIALIZED = "INITIALIZED" NOT_TRANSMITTED = "NOT_TRANSMITTED" TRANSMITTED = "TRANSMITTED" @@ -22,9 +32,16 @@ class ExecutionState(str, Enum): QUEUED_GATEWAY_SIDE = "QUEUED_GATEWAY_SIDE" QUEUED_SERVER_SIDE = "QUEUED_SERVER_SIDE" + @classmethod + def _missing_(cls, value): # type: ignore + _LOGGER.warning(f"Unsupported value {value} has been returned for {cls}") + return cls.UNKNOWN + @unique class ExecutionSubType(str, Enum): + UNKNOWN = "UNKNOWN" + _ = "-" ACTION_GROUP = "ACTION_GROUP" ACTION_GROUP_SEQUENCE = "ACTION_GROUP_SEQUENCE" DAWN_TRIGGER = "DAWN_TRIGGER" @@ -37,3 +54,8 @@ class ExecutionSubType(str, Enum): NO_ERROR = "NO_ERROR" P2P_COMMAND_REGULATION = "P2P_COMMAND_REGULATION" TIME_TRIGGER = "TIME_TRIGGER" + + @classmethod + def _missing_(cls, value): # type: ignore + _LOGGER.warning(f"Unsupported value {value} has been returned for {cls}") + return cls.UNKNOWN diff --git a/tests/test_enums.py b/tests/test_enums.py index 4b73ea7d..c8f4499d 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -1,4 +1,11 @@ -from pyoverkiz.enums import EventName, FailureType, GatewaySubType, GatewayType +from pyoverkiz.enums import ( + EventName, + ExecutionSubType, + ExecutionType, + FailureType, + GatewaySubType, + GatewayType, +) class TestGatewayType: @@ -30,3 +37,13 @@ def test_missing(self): class TestFailureType: def test_missing(self): assert FailureType(99) == FailureType.UNKNOWN + + +class TestExecutionType: + def test_missing(self): + assert ExecutionType("test") == ExecutionType.UNKNOWN + + +class TestExecutionSubType: + def test_missing(self): + assert ExecutionSubType("test") == ExecutionSubType.UNKNOWN