Repository navigation
Bootstrap pytest scaffold with golden-path tests for entity-reference extractors - #1254
frenckatron wants to merge 2 commits into
Conversation
… extractors Spook had no test infrastructure. This adds: - A `tests/` package with `conftest.py` enabling pytest-homeassistant-custom-component. - 47 golden-path tests pinning the current behavior of the two riskiest extractors: - `ectoplasms/automation/repairs/unknown_entity_references.py` module-level helpers - `ectoplasms/lovelace/repairs/unknown_entity_references.py` private dashboard walker - A `Tests` GitHub Actions workflow that runs `pytest` on every push and PR. - `pytest-homeassistant-custom-component` added to `tool.uv.dev-dependencies`. - `requires-python` bumped from `>=3.13` to `>=3.13.2` to match the floor that current Home Assistant releases (and the pytest plugin) require. The tests lock down behavior before the upcoming flatten/refactor of the two extractors so any regression there will fail loudly.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add module-level tests for the synchronous, hass-free helpers that the existing scaffold did not yet pin down: - `tests/ectoplasms/script/repairs/test_unknown_entity_references.py` covers the `extract_entities_from_trigger_config` walker used by the script repair to harvest entity IDs out of blueprint trigger inputs. - `tests/test_util.py` covers the three pure helpers in `custom_components/spook/util.py` that ectoplasms rely on: `is_template_string`, `split_comma_separated_entity_ids`, and `extract_template_strings_from_config`. The async, hass-aware helpers in `util.py` and the rest of the script repair remain integration-test territory. 84 tests pass locally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
|
Closing this as superseded by #1274. The useful helper/script extractor tests were ported there using the project PR template. The remaining scaffold/workflow/dependency/lockfile changes in this draft are stale and conflict with current main. |


What
Bootstrap a pytest scaffold for Spook using
pytest-homeassistant-custom-component, and pin down the synchronous, hass-free extractor helpers used by the entity-reference repairs and shared utilities.Why
Spook had no test harness at all. Without one, every refactor — like the planned consolidation of the four-way per-domain unknown-reference repairs into a single recursive walker, or the upcoming
repairs.pybase-class extraction — has to be reviewed by hand. The HA core'spytest-homeassistant-custom-componentplugin gives us a realhassfixture and matches the workflow contributors already know.How
pyproject.tomlgetspytest-homeassistant-custom-componentindev-dependenciesand a[tool.pytest.ini_options]block withasyncio_mode = "auto"so plainasync deftests don't each need@pytest.mark.asyncio.requires-pythonis bumped to>=3.13.2to match the plugin's HA pin..github/workflows/test.yamlrunsuv sync --frozen --devanduv run pytest tests -von every push and PR on Python 3.13.tests/conftest.pyautouse-enablesenable_custom_integrationsso Spook is loadable in every test.tests/ectoplasms/automation/repairs/test_unknown_entity_references.py—extract_entities_from_value,extract_entities_from_trigger_config,extract_entities_from_condition_config,extract_entities_from_action_config, and theextract_entities_from_automation_configorchestrator.tests/ectoplasms/lovelace/repairs/test_unknown_entity_references.py— dashboard, card, badge, and element walkers.tests/ectoplasms/script/repairs/test_unknown_entity_references.py— the syncextract_entities_from_trigger_configblueprint-input walker.tests/test_util.py— the three sync helpers reused across ectoplasms (is_template_string,split_comma_separated_entity_ids,extract_template_strings_from_config).Testing
uv sync --frozen --devuv run pytest tests -v→ 84 passed in 0.83s locally.uv run ruff check tests/anduv run ruff format --check tests/are clean.Quality Report
Changes: 16 files changed, 2412 insertions(+), 1225 deletions(-)
Code scan: 1 issue(s) found
uv.lock:0— 1482 lines addedTests: failed (command not found)
Branch hygiene: 1 issue(s)
Generated by Kōan post-mission quality pipeline