This commit is contained in:
epenet 2025-07-01 08:02:31 +00:00
parent e50f5f9309
commit 86f1de056e
2 changed files with 13 additions and 16 deletions

View File

@ -20,7 +20,4 @@ class DhcpServiceInfo(BaseServiceInfo):
""" """
def __post_init__(self) -> None: def __post_init__(self) -> None:
"""Post-init processing.""" """Post init checks."""
# Ensure macaddress is always a lowercase string without colons
if self.macaddress != self.macaddress.lower().replace(":", ""):
raise ValueError("macaddress is not correctly formatted")

View File

@ -156,6 +156,18 @@ asyncio.set_event_loop_policy(runner.HassEventLoopPolicy(False))
asyncio.set_event_loop_policy = lambda policy: None asyncio.set_event_loop_policy = lambda policy: None
def _dhcp_service_info_post_init(self: DhcpServiceInfo) -> None:
"""Post-init processing for DhcpServiceInfo.
Ensure that the macaddress is always in lowercase and without colons to match DHCP service.
"""
if self.macaddress != self.macaddress.lower().replace(":", ""):
raise ValueError("macaddress is not correctly formatted")
DhcpServiceInfo.__post_init__ = _dhcp_service_info_post_init
def pytest_addoption(parser: pytest.Parser) -> None: def pytest_addoption(parser: pytest.Parser) -> None:
"""Register custom pytest options.""" """Register custom pytest options."""
parser.addoption("--dburl", action="store", default="sqlite://") parser.addoption("--dburl", action="store", default="sqlite://")
@ -2079,15 +2091,3 @@ def disable_block_async_io() -> Generator[None]:
blocking_call.object, blocking_call.function, blocking_call.original_func blocking_call.object, blocking_call.function, blocking_call.original_func
) )
calls.clear() calls.clear()
def _dhcp_service_info_post_init(self: DhcpServiceInfo) -> None:
"""Post-init processing for DhcpServiceInfo.
Ensure that the macaddress is always in lowercase and without colons to match DHCP service.
"""
if self.macaddress != self.macaddress.lower().replace(":", ""):
raise ValueError("macaddress is not correctly formatted")
DhcpServiceInfo.__post_init__ = _dhcp_service_info_post_init