Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
44fcd53
docs: add design spec for HA test-harness migration
rhammen Jul 25, 2026
1143bf1
test: adopt pytest-homeassistant-custom-component harness with Window…
rhammen Jul 25, 2026
8cd0c0c
test: prevent zaptec_constants fixture from clobbering HA event-loop …
rhammen Jul 25, 2026
6eb68ac
test: add real-harness setup fixtures (mock Zaptec client + MockConfi…
rhammen Jul 25, 2026
bcdb186
test: behavior coverage for ZaptecUpdateCoordinator via real harness
rhammen Jul 25, 2026
cedc13b
test: behavior coverage for ZaptecBaseEntity; xfail documents #410
rhammen Jul 25, 2026
b74943c
test: remove temporary harness smoke test, cover coordinator/entity gaps
rhammen Jul 25, 2026
911d59b
test: document _backed_get MISSING-default/no-normalization divergence
rhammen Jul 25, 2026
0ecebab
test: assert correct entity-availability behavior (#410 is not a bug)
rhammen Jul 25, 2026
650e888
test: unpin pytest-hacc so CI 3.13 matrix leg can install
rhammen Jul 25, 2026
ffa2f78
test: pin pytest-hacc per-Python via markers to match reverted HA on …
rhammen Jul 25, 2026
5475a3b
test: decouple test-job install from requirements.txt (pytest-hacc ow…
rhammen Jul 25, 2026
221406a
test: make requirements.txt + pytest-hacc coexist (relax pydantic pin)
rhammen Jul 25, 2026
06c3eeb
docs: rework HA-harness migration to Linux-native + Option C (#257)
rhammen Jul 26, 2026
95b0800
test: drop committed Windows shim; rely on Linux pytest-hacc autoload
rhammen Jul 26, 2026
70ed43f
ci: run harness + API-client tests as two scoped pytest invocations
rhammen Jul 26, 2026
a77a9b7
test: scripts/test runs harness + API-client invocations, combined co…
rhammen Jul 26, 2026
3ba66e8
docs: explain two-invocation test split (harness vs API-client, #257)
rhammen Jul 26, 2026
6550f73
test: normalize keys in _backed_get via to_under, matching ZaptecBase…
rhammen Jul 26, 2026
b8f212a
test: pin charging-interval test to named constants, keep the relatio…
rhammen Jul 26, 2026
057af4b
test: explain non-obvious white-box test rationale, cover 4th log-for…
rhammen Jul 26, 2026
0b79410
test: explain the mock-name coupling behind test_init.py's entity filter
rhammen Jul 26, 2026
7611e67
test: explain three non-obvious setup choices in trigger_poll/constru…
rhammen Jul 26, 2026
6858e82
test: explain four non-obvious fixture/mock choices in conftest.py
rhammen Jul 26, 2026
4361b0a
docs: remove planning docs (archived to docs/ai-planning-archive)
rhammen Jul 26, 2026
5d9cdaf
merge: pull in upstream #413 (redaction) and #408 (AI policy)
rhammen Jul 26, 2026
9464908
test: drop in-code issue references flagged in PR #414 review
rhammen Jul 26, 2026
e3a7c68
test: split zaptec_constants into tests/zaptec/conftest.py
rhammen Jul 27, 2026
01d997d
test: trim redundant comment block in requirements_test.txt
rhammen Jul 27, 2026
55a5ed1
test: trim wordy docstrings/comments flagged in PR #414 review
rhammen Jul 27, 2026
e1766d4
Refactor services.py: register once in async_setup, fix multi-account…
rhammen Jul 28, 2026
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
8 changes: 6 additions & 2 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ jobs:
-r requirements.txt \
-r requirements_test.txt

- name: Tests suite
- name: Tests suite (HA integration — harness)
run: |
pytest --cov=./custom_components/zaptec --cov-branch
pytest tests --ignore=tests/zaptec --cov=./custom_components/zaptec --cov-branch

- name: Tests suite (API client — plain pytest, no harness)
run: |
pytest tests/zaptec -p no:homeassistant --cov=./custom_components/zaptec --cov-branch --cov-append

18 changes: 18 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,24 @@ To run tests and check test coverage:
report, or enable the "Coverage Gutters" extension to view the coverage
directly in VSCode.

The suite runs as **two pytest invocations**, and `./scripts/test` runs both:

- **HA-integration tests** (`tests/test_*.py`) run under the
`pytest-homeassistant-custom-component` harness, which autoloads on Linux.
Run directly with:
`pytest tests --ignore=tests/zaptec --cov=./custom_components/zaptec --cov-branch`
- **API-client tests** (`tests/zaptec/*`) test the vendored `zaptec/` client,
which is destined to become a standalone PyPI library (issue #257) and has no
Home Assistant dependency. They run as plain pytest with the harness disabled
(the harness blocks non-localhost sockets, which would break their live
`api.zaptec.com/api/constants` call):
`pytest tests/zaptec -p no:homeassistant --cov=./custom_components/zaptec --cov-branch --cov-append`

Because the harness (and its socket block) is process-wide, a bare `pytest`
is not the entry point — use `./scripts/test` or the two commands above. The
HA-integration tests require Linux; run them in the Dev Container (native
Windows is not supported for that half). `tests/zaptec/*` run anywhere.

HA requires [95% coverage](https://developers.home-assistant.io/docs/core/integration-quality-scale/rules/test-coverage/)
for all core integration modules, and while HACS doesn't have the same
requirements, reaching this level is still a goal for this integration.
Expand Down
21 changes: 14 additions & 7 deletions custom_components/zaptec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryError, ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import ConfigType

from .const import (
CONF_CHARGERS,
Expand All @@ -24,7 +25,7 @@
)
from .coordinator import ZaptecUpdateCoordinator, ZaptecUpdateOptions
from .manager import ZaptecConfigEntry, ZaptecManager
from .services import async_setup_services, async_unload_services
from .services import async_setup_services
from .zaptec import (
RETRYABLE_HTTP_STATUSES,
AuthenticationError,
Expand Down Expand Up @@ -70,6 +71,17 @@ def _config_entry_error(
]


async def async_setup(hass: HomeAssistant, _config: ConfigType) -> bool:
"""Set up the zaptec integration's services.

Called once at Home Assistant startup, independent of how many zaptec
config entries exist, so services are available regardless of which
(or how many) accounts are configured.
"""
await async_setup_services(hass)
return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up zaptec as config entry."""

Expand Down Expand Up @@ -205,9 +217,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# in various HA functions.
entry.runtime_data = manager

# Setup services
await async_setup_services(hass, manager)

# Setup all platforms
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(async_reload_entry))
Expand Down Expand Up @@ -282,9 +291,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ZaptecConfigEntry) -> b

manager = entry.runtime_data
await manager.cancel_streams()
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
await async_unload_services(hass)
return unload_ok
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)


async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
Expand Down
Loading
Loading