Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,36 @@ updates:
- "dependencies"
- "python"
ignore:
# pytest-homeassistant-custom-component pins pytest EXACTLY, because it
# carries the whole of HA core's test requirements. Raising our floor past
# that pin cannot resolve, however long the pull request stays open, so
# the only move is to let phacc bring pytest forward on its own schedule.
# pytest-homeassistant pins pytest EXACTLY, because it carries HA core's
# test requirements. Raising our floor past that pin cannot resolve,
# however long the pull request stays open, so the only move is to let
# pytest-homeassistant bring pytest forward on its own schedule.
- dependency-name: pytest
groups:
# HA pins these exactly (directly or via integration manifests), so they
# must move in lockstep with the homeassistant version under test.
homeassistant:
patterns:
- "homeassistant"
- "pytest-homeassistant-custom-component"
- "pytest-homeassistant"
- "aioesphomeapi"
- "aiofiles"
- "aiohasupervisor"
- "aiousbwatcher"
- "av"
- "colorlog"
- "debugpy"
- "fnv-hash-fast"
- "ha-silabs-firmware-client"
- "matter-python-client"
- "numpy"
- "psutil-home-assistant"
- "pyserial"
- "PyTurboJPEG"
- "pyudev"
- "SQLAlchemy"
- "universal-silabs-flasher"
- "usb-devices"
- "zeroconf"
- "zha"
- "zha-quirks"
- "zwave-js-server-python"
Expand Down
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ If you test with stale JavaScript, the Lovelace strategy will fail with:

## Testing Notes

- Uses `pytest-homeassistant-custom-component` for HA test utilities
- Uses Home Assistant's `pytest-homeassistant` for HA test utilities (import from
`pytest_homeassistant.common`; pin it to the same version as `homeassistant`)
- `tests/conftest.py`: Shared fixtures (`mock_lock_config_entry`, `lock_code_manager_config_entry`)
- `tests/common.py`: `MockLCMLock` (in-memory provider), mock entities, test constants
- Fault knobs on `MockLCMLock` (`ignore`, `refuse`, `fail`, `hang`, `drop_reply`, `slow`),
Expand Down
19 changes: 11 additions & 8 deletions custom_components/lock_code_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
EVENT_LOVELACE_UPDATED,
)
from homeassistant.core import (
DOMAIN as HOMEASSISTANT_DOMAIN,
CoreState,
Event,
HomeAssistant,
Expand Down Expand Up @@ -237,7 +238,7 @@ def _entry_schema(fields: dict[Any, Any]) -> vol.Schema:

async def async_migrate_entry(
hass: HomeAssistant, config_entry: LockCodeManagerConfigEntry
) -> bool:
) -> None:
"""Migrate old entry data to new format."""
# The unmanaged-code sweep runs against the finished entry, at the bottom,
# not from the step that introduced it: it asks every entry what it
Expand Down Expand Up @@ -497,8 +498,6 @@ async def async_migrate_entry(
# configuration users will actually have.
await async_sweep_unmanaged_codes(hass, config_entry)

return True


@callback
def _async_notify_lovelace_dashboards(hass: HomeAssistant) -> None:
Expand Down Expand Up @@ -1000,7 +999,7 @@ def _clear_post_start_setup() -> None:

async def async_setup_entry(
hass: HomeAssistant, config_entry: LockCodeManagerConfigEntry
) -> bool:
) -> None:
"""Set up a config entry."""
ent_reg = er.async_get(hass)
try:
Expand Down Expand Up @@ -1053,8 +1052,6 @@ def _safe_unsub() -> None:

config_entry.async_on_unload(_safe_unsub)

return True


async def async_unload_lock(
hass: HomeAssistant,
Expand Down Expand Up @@ -1148,7 +1145,7 @@ async def _async_release_locks(

async def async_unload_entry(
hass: HomeAssistant, config_entry: LockCodeManagerConfigEntry
) -> bool:
) -> None:
"""Unload an entry, stopping its slots before tearing down platforms."""
hass_data = hass.data[DATA]
runtime_data = config_entry.runtime_data
Expand Down Expand Up @@ -1198,7 +1195,13 @@ async def async_unload_entry(
if not other_loaded_entries:
await _async_cleanup_strategy_resource(hass, hass_data)

return unload_ok
# Raised last rather than through async_unload_platforms_or_raise, so a
# failed platform unload still releases the strategy resource above.
if not unload_ok:
raise ConfigEntryError(
translation_domain=HOMEASSISTANT_DOMAIN,
translation_key="unload_platforms_failed",
)


async def async_remove_entry(
Expand Down
1 change: 0 additions & 1 deletion custom_components/lock_code_manager/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ class LockCodeManagerFlowHandler(
"""Config flow for Lock Code Manager."""

VERSION = 5
CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_POLL

def __init__(self) -> None:
"""Initialize config flow."""
Expand Down
6 changes: 5 additions & 1 deletion custom_components/lock_code_manager/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
get_entry_config,
get_loaded_config_entry,
slots_configured_on,
subentry_id_for_slot,
)
from .providers import BaseLock

Expand Down Expand Up @@ -1088,7 +1089,10 @@ def _send_update(next_event: dict[str, Any] | None = None) -> None:
# which a card cannot tell apart from "entities not created yet"
# during setup. So it would keep rendering the departed person, tinted
# active, named "Unnamed".
if not get_entry_config(config_entry).has_slot(slot_num):
# Read from the entry's subentries, not the cached config: Home
# Assistant removes a deleted subentry's entities before the update
# listener refreshes that cache, and those removals land here.
if subentry_id_for_slot(config_entry, slot_num) is None:
connection.send_event(
msg["id"], {ATTR_SLOT_NUM: slot_num, ATTR_REMOVED: True}
)
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "Lock Code Manager",
"zip_release": true,
"filename": "lock_code_manager.zip",
"homeassistant": "2026.10.0",
"homeassistant": "2026.11.0",
"render_readme": true
}
13 changes: 10 additions & 3 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@
-r requirements_test.txt
aioesphomeapi==46.25.1
aiofiles==25.1.0
aiohasupervisor==0.8.1
aiousbwatcher==1.1.2
av==19.0.0
colorlog==6.12.0
debugpy==1.8.22
fnv-hash-fast==2.0.3
ha-silabs-firmware-client==0.4.0
homeassistant>=2026.10.4
homeassistant>=2026.11.3
matter-python-client==1.5.5
numpy==2.3.2
psutil-home-assistant==0.0.1
pyserial==3.5
PyTurboJPEG==1.8.3
pyudev==0.24.5
SQLAlchemy==2.0.54
universal-silabs-flasher==1.3.0
usb-devices>=0.5.1
uv
zha==2.4.2
zha-quirks==2.4.0
zha==2.4.3
zha-quirks==2.4.1
zwave-js-server-python==0.74.0
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
hypothesis>=6.170.17
pylint-strict-informational>=0.1
pytest>=9.0.3
pytest-homeassistant-custom-component==0.13.375
pytest-homeassistant==2026.11.3
# Declared directly rather than leaned on transitively: `timeout` in
# pyproject.toml degrades to a warning if this goes missing, so the
# protection would vanish silently.
Expand Down
13 changes: 6 additions & 7 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import freezegun.api
from freezegun.api import FrozenDateTimeFactory
import pytest
from pytest_homeassistant_custom_component.common import (
from pytest_homeassistant.common import (
MockConfigEntry,
MockModule,
MockPlatform,
Expand Down Expand Up @@ -1772,20 +1772,19 @@ async def async_setup_mock_lock_entry(hass: HomeAssistant) -> MockConfigEntry:

async def async_setup_entry_init(
hass: HomeAssistant, config_entry: ConfigEntry
) -> bool:
) -> None:
"""Set up test config entry."""
await hass.config_entries.async_forward_entry_setups(
config_entry, [Platform.CALENDAR, Platform.LOCK]
)
return True

async def async_unload_entry_init(
hass: HomeAssistant, config_entry: ConfigEntry
) -> bool:
) -> None:
"""Unload test config entry."""
for platform in (Platform.CALENDAR, Platform.LOCK):
await hass.config_entries.async_forward_entry_unload(config_entry, platform)
return True
await hass.config_entries.async_unload_platforms_or_raise(
config_entry, [Platform.CALENDAR, Platform.LOCK]
)

mock_platform(hass, f"{LOCK_DEVICE_DOMAIN}.config_flow")
mock_integration(
Expand Down
20 changes: 15 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from hypothesis import settings as hypothesis_settings
from probatio import to_field_list
import pytest
from pytest_homeassistant_custom_component.common import (
from pytest_homeassistant.common import (
MockConfigEntry,
async_fire_time_changed,
mock_config_flow,
Expand Down Expand Up @@ -45,8 +45,6 @@
release_all_faults,
)

pytest_plugins = ["pytest_homeassistant_custom_component"]

# Hypothesis profiles: "dev" keeps the full-suite run within its
# seconds budget; CI opts into deeper exploration via HYPOTHESIS_PROFILE=ci.
# deadline=None in both: per-example deadlines flake under the HA test
Expand Down Expand Up @@ -103,6 +101,18 @@ def auto_enable_custom_integrations(enable_custom_integrations):
yield


@pytest.fixture
def hass_config_dir(hass_tmp_config_dir: str) -> str:
"""
Give each test its own temporary config directory.

pytest-homeassistant otherwise shares ``tests/testing_config``, and Home
Assistant writes its default blueprints there, into the repository and
across parallel workers.
"""
return hass_tmp_config_dir


@pytest.fixture(autouse=True)
def auto_setup_mock_lock():
"""Automatically set up MockLCMLock for all tests."""
Expand Down Expand Up @@ -180,8 +190,8 @@ async def _converted(self, *args: Any, **kwargs: Any) -> FlowResult:
# the integration.
DEPRECATED_USE_FORMATS = frozenset(
{
"The deprecated %s %s was %s from %s.%s Use %s instead, please %s",
"The deprecated %s %s was %s from %s.%s Use %s instead",
"The deprecated %s %s was %s from %s.%s%s%s %s",
"The deprecated %s %s was %s from %s.%s%s",
}
)

Expand Down
2 changes: 1 addition & 1 deletion tests/properties/test_manages_predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from typing import Any

from hypothesis import given, strategies as st
from pytest_homeassistant_custom_component.common import (
from pytest_homeassistant.common import (
MockConfigEntry,
async_test_home_assistant,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/properties/test_shared_lock_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
rule,
)
import pytest
from pytest_homeassistant_custom_component.common import (
from pytest_homeassistant.common import (
INSTANCES,
MockConfigEntry,
async_test_home_assistant,
Expand Down
2 changes: 1 addition & 1 deletion tests/properties/test_validation_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import asyncio

from hypothesis import given, strategies as st
from pytest_homeassistant_custom_component.common import (
from pytest_homeassistant.common import (
MockConfigEntry,
async_test_home_assistant,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/akuvox/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from unittest.mock import AsyncMock

import pytest
from pytest_homeassistant_custom_component.common import MockConfigEntry
from pytest_homeassistant.common import MockConfigEntry

from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import (
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/akuvox/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from freezegun.api import FrozenDateTimeFactory
import pytest
from pytest_homeassistant_custom_component.common import MockConfigEntry
from pytest_homeassistant.common import MockConfigEntry

from homeassistant.const import (
ATTR_ENTITY_ID,
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/akuvox/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from unittest.mock import AsyncMock, patch

import pytest
from pytest_homeassistant_custom_component.common import MockConfigEntry
from pytest_homeassistant.common import MockConfigEntry

from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from unittest.mock import AsyncMock, MagicMock

import pytest
from pytest_homeassistant_custom_component.common import MockConfigEntry
from pytest_homeassistant.common import MockConfigEntry

from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant, SupportsResponse
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/matter/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from matter_server.common.const import SCHEMA_VERSION
from matter_server.common.models import ServerInfoMessage
import pytest
from pytest_homeassistant_custom_component.common import MockConfigEntry
from pytest_homeassistant.common import MockConfigEntry

from homeassistant.components.matter.const import CREDENTIAL_TYPE_REVERSE_MAP
from homeassistant.const import (
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/matter/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from matter_server.client.models.node import MatterNode
from matter_server.common.helpers.util import dataclass_from_dict
from matter_server.common.models import MatterNodeData
from pytest_homeassistant_custom_component.common import MockConfigEntry
from pytest_homeassistant.common import MockConfigEntry

from homeassistant.core import HomeAssistant

Expand Down
2 changes: 1 addition & 1 deletion tests/providers/matter/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from matter_server.client.models.node import MatterNode
from matter_server.common.models import EventType, MatterNodeEvent
import pytest
from pytest_homeassistant_custom_component.common import (
from pytest_homeassistant.common import (
MockConfigEntry,
async_capture_events,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/matter/test_node_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from matter_server.common.errors import NodeNotResolving, UnknownError
from matter_server.common.models import EventType
import pytest
from pytest_homeassistant_custom_component.common import MockConfigEntry
from pytest_homeassistant.common import MockConfigEntry

from homeassistant.components.matter import lock_helpers
from homeassistant.const import STATE_ON
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/matter/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from matter_server.common.errors import UnknownError
from matter_server.common.models import EventType, MatterNodeEvent
import pytest
from pytest_homeassistant_custom_component.common import MockConfigEntry
from pytest_homeassistant.common import MockConfigEntry

from homeassistant.components.matter.helpers import get_node_from_device_entry
from homeassistant.config_entries import ConfigEntryState
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/schlage/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from unittest.mock import AsyncMock, patch

import pytest
from pytest_homeassistant_custom_component.common import MockConfigEntry
from pytest_homeassistant.common import MockConfigEntry

from homeassistant.const import (
CONF_ENABLED,
Expand Down
Loading
Loading