Add pytest infrastructure #3

Merged
mat merged 2 commits from test/infra into main 2026-04-24 12:38:05 +00:00
Owner

Summary

  • Adds requirements-test.txt (pytest, pytest-homeassistant-custom-component, comwatt-client), pytest.ini (asyncio auto-mode, testpaths), tests/__init__.py, and tests/conftest.py with an auto-enabled custom-integrations fixture and a mock_comwatt_client fixture that patches every import site of ComwattClient.
  • tests/test_smoke.py sanity-checks the plumbing and validates manifest invariants (domain, config_flow, requirements).

Test plan

  • pytest tests/test_smoke.py passes locally (2 passed)
  • Will be re-verified once PR8 wires pytest into CI

Follow-ups

  • Follow-up PRs add config-flow, __init__, sensor and switch tests on top of this scaffolding.
  • Each later PR is independent off main; this one should merge first.
## Summary - Adds `requirements-test.txt` (pytest, `pytest-homeassistant-custom-component`, `comwatt-client`), `pytest.ini` (asyncio auto-mode, testpaths), `tests/__init__.py`, and `tests/conftest.py` with an auto-enabled custom-integrations fixture and a `mock_comwatt_client` fixture that patches every import site of `ComwattClient`. - `tests/test_smoke.py` sanity-checks the plumbing and validates manifest invariants (`domain`, `config_flow`, `requirements`). ## Test plan - [x] `pytest tests/test_smoke.py` passes locally (2 passed) - [ ] Will be re-verified once PR8 wires pytest into CI ## Follow-ups - Follow-up PRs add config-flow, `__init__`, sensor and switch tests on top of this scaffolding. - Each later PR is independent off `main`; this one should merge first.
(AI) Add pytest infrastructure
Some checks failed
Validate / validate-hacs (push) Failing after 2s
Validate / validate-hassfest (push) Failing after 2s
Validate / validate-hacs (pull_request) Failing after 2s
Validate / validate-hassfest (pull_request) Failing after 2s
253d3d9515
Adds the plumbing needed to run Home Assistant custom-integration tests:

- `requirements-test.txt` pins `pytest-homeassistant-custom-component`
  (which transitively pulls `homeassistant`) and the runtime dependency
  `comwatt-client`.
- `pytest.ini` enables `asyncio_mode = auto` and points pytest at
  `tests/`.
- `tests/conftest.py` loads the pytest-homeassistant-custom-component
  plugin, auto-enables custom integrations, and exposes a
  `mock_comwatt_client` fixture that patches every import site of
  `ComwattClient` used by the integration.
- `tests/test_smoke.py` exercises the plumbing and asserts basic
  manifest/domain invariants.

Follow-up PRs will add config-flow, init, sensor, and switch tests on
top of this scaffolding.
🐛 (AI) Fix cookie jar mock in test fixture
Some checks failed
Validate / validate-hacs (push) Failing after 2s
Validate / validate-hassfest (push) Failing after 2s
Validate / validate-hacs (pull_request) Failing after 2s
Validate / validate-hassfest (pull_request) Failing after 2s
b11e0f168e
`_make_fake_client` assigned a plain list to `session.cookies` then
tried to attach a `get_dict` attribute to it, which fails because
lists don't accept arbitrary attributes. Introduce `_FakeCookieJar`, a
list subclass that answers `get_dict()` the way `requests`' own
`RequestsCookieJar` does, so both iteration (used by the config flow)
and `get_dict()` (used by the integration to snapshot the session)
work against the mock.
mat force-pushed test/infra from b11e0f168e
Some checks failed
Validate / validate-hacs (push) Failing after 2s
Validate / validate-hassfest (push) Failing after 2s
Validate / validate-hacs (pull_request) Failing after 2s
Validate / validate-hassfest (pull_request) Failing after 2s
to 05511bb47b
Some checks failed
Validate / validate-hacs (push) Failing after 2s
Validate / validate-hassfest (push) Failing after 2s
Validate / validate-hacs (pull_request) Failing after 2s
Validate / validate-hassfest (pull_request) Failing after 2s
2026-04-24 10:01:33 +00:00
Compare
mat force-pushed test/infra from 05511bb47b
Some checks failed
Validate / validate-hacs (push) Failing after 2s
Validate / validate-hassfest (push) Failing after 2s
Validate / validate-hacs (pull_request) Failing after 2s
Validate / validate-hassfest (pull_request) Failing after 2s
to 2b1b7e8ff9
Some checks failed
Validate / validate-hacs (push) Failing after 2s
Validate / validate-hassfest (push) Failing after 2s
Validate / validate-hacs (pull_request) Failing after 2s
Validate / validate-hassfest (pull_request) Failing after 2s
2026-04-24 12:24:35 +00:00
Compare
mat changed title from (AI) Add pytest infrastructure to Add pytest infrastructure 2026-04-24 12:25:49 +00:00
mat force-pushed test/infra from 2b1b7e8ff9
Some checks failed
Validate / validate-hacs (push) Failing after 2s
Validate / validate-hassfest (push) Failing after 2s
Validate / validate-hacs (pull_request) Failing after 2s
Validate / validate-hassfest (pull_request) Failing after 2s
to 7b9d0f11b0
All checks were successful
Validate / validate-hacs (push) Has been skipped
Validate / validate-hassfest (push) Has been skipped
Validate / validate-hacs (pull_request) Has been skipped
Validate / validate-hassfest (pull_request) Has been skipped
2026-04-24 12:34:34 +00:00
Compare
mat merged commit c7ee4feaf8 into main 2026-04-24 12:38:05 +00:00
mat deleted branch test/infra 2026-04-24 12:38:05 +00:00
mat referenced this pull request from a commit 2026-04-24 12:38:07 +00:00
mat referenced this pull request from a commit 2026-04-24 12:38:30 +00:00
mat referenced this pull request from a commit 2026-04-24 12:38:37 +00:00
mat referenced this pull request from a commit 2026-04-24 12:38:54 +00:00
mat referenced this pull request from a commit 2026-04-24 12:39:02 +00:00
mat referenced this pull request from a commit 2026-04-24 12:59:40 +00:00
mat referenced this pull request from a commit 2026-04-24 21:51:56 +00:00
mat referenced this pull request from a commit 2026-04-24 21:51:56 +00:00
mat referenced this pull request from a commit 2026-04-24 21:51:56 +00:00
mat referenced this pull request from a commit 2026-04-24 21:51:56 +00:00
mat referenced this pull request from a commit 2026-04-24 21:51:56 +00:00
mat referenced this pull request from a commit 2026-04-24 21:51:56 +00:00
mat referenced this pull request from a commit 2026-04-24 21:51:56 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mat/homeassistant-comwatt!3
No description provided.