Skip to content
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1ebe4f7
Rough idea, not working though
CoMPaTech Jul 2, 2025
ee014cc
Change to generic approach
CoMPaTech Jul 7, 2025
75bb31c
Add binary_sensor snapshot
CoMPaTech Jul 7, 2025
d04fac7
Smaller approach
CoMPaTech Jul 8, 2025
afb8ede
Remove replaced binary_sensor testcase
bouwew Aug 2, 2025
7615062
Remove replaced climate testcase
bouwew Aug 2, 2025
2c8e0b7
Remove replaced sensor testcase
bouwew Aug 2, 2025
8774a02
Add switch snapshot testing
bouwew Aug 2, 2025
11c1b6c
Save added switch snapshot
bouwew Aug 2, 2025
d31dcad
Remove replaced switch testcase
bouwew Aug 2, 2025
1307227
Replace switch stretch testcase by snapshot testing
bouwew Aug 2, 2025
9169b8e
Save updated switch snapshot
bouwew Aug 2, 2025
6c02d6f
Add adam snapshot testcase
bouwew Aug 2, 2025
a1d67c4
Save updated sensor snapshot
bouwew Aug 2, 2025
eaf1d7f
Replace two more sensor testcases
bouwew Aug 2, 2025
576fd48
Save updated sensor snapshot
bouwew Aug 2, 2025
3648b8d
Remove replaced testcase
bouwew Aug 2, 2025
c4f6489
More sensor test updates
bouwew Aug 2, 2025
f1e1b39
Save updates/removals
bouwew Aug 2, 2025
865d9af
Docstring improvements
bouwew Aug 2, 2025
224f7b8
Shorten switch testcase names
bouwew Aug 2, 2025
c9ff831
Improve sensor testcase name
bouwew Aug 2, 2025
6f1f828
Add select snapshot test
bouwew Aug 2, 2025
cbc8518
Save updates
bouwew Aug 2, 2025
002ffa0
Add-replace a 2nd select snapshot testcase
bouwew Aug 2, 2025
b12931b
Improve docstring
bouwew Aug 2, 2025
c7a8ab5
Avoid testcase name collision
bouwew Aug 2, 2025
1a6548f
Save updates
bouwew Aug 2, 2025
ebad3df
Add/update number snapshot tests
bouwew Aug 2, 2025
f02bf76
Save new snapshot
bouwew Aug 2, 2025
48bf4fd
Add/improve climate snapshot tests
bouwew Aug 2, 2025
ba71aac
Save updated climate snapshot
bouwew Aug 2, 2025
6623567
Add/update binary_sensor snapshot testing
bouwew Aug 2, 2025
d5a10d2
Save updated binary_sensor snapshot, cleanup
bouwew Aug 2, 2025
b74fea4
Revert deletion of binary_sensor testcase
bouwew Aug 2, 2025
eccf41d
Add/update button snapshot testing
bouwew Aug 2, 2025
5379196
Save updates
bouwew Aug 2, 2025
648d3cb
Update script as suggested
bouwew Aug 2, 2025
f961de2
Remove async as suggested
bouwew Aug 2, 2025
665ae66
Fix typo
bouwew Aug 2, 2025
b76506b
Revert reordering
bouwew Aug 2, 2025
583f670
More fixes
bouwew Aug 2, 2025
f3c97ef
Test-button: try without block_till_done()
bouwew Aug 4, 2025
a4b76db
Update binary_sensor tests
bouwew Aug 9, 2025
a9d8916
Save updated snapshot
bouwew Aug 9, 2025
a875c9b
Formatting
bouwew Aug 10, 2025
f18e1ae
Add comment, update docstring
bouwew Aug 10, 2025
db10282
Line up with Core tests
bouwew Oct 4, 2025
991b89d
Save updated snapshot files, ruff fixes
bouwew Oct 4, 2025
9df73bc
Re-ruffed via precommit
bouwew Oct 4, 2025
2f72b01
CRAI improvement
bouwew Oct 4, 2025
452190f
Revert delete of notification testcase
bouwew Oct 4, 2025
31872fa
Update CHANGELOG
bouwew Oct 4, 2025
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
23 changes: 21 additions & 2 deletions scripts/core-testing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,24 @@ if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "testing" ] ; then
if [ ! "${DEBUG}" == "" ] ; then
debug_params="-rpP --log-cli-level=DEBUG"
fi
# shellcheck disable=SC2086
pytest ${debug_params} ${subject} tests/components/${REPO_NAME}/${basedir} --snapshot-update --cov=homeassistant/components/${REPO_NAME}/ --cov-report term-missing || exit
# First test if snapshots still valid (silent fail, otherwise will update snapshots)
SNAPSHOT_UPDATED=0
PYTEST_COMMAND="pytest ${debug_params} ${subject} tests/components/${REPO_NAME}/${basedir} --cov=homeassistant/components/${REPO_NAME}/ --cov-report term-missing"
eval "${PYTEST_COMMAND}" || {
echo ""
echo -e "${CFAIL}Pytest / Snapshot validation failed, re-running to update snapshot ...${CNORM}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I skipped those 'CRAI wants handbrakes on everything' :) But good enough - mind you the script is flawed when translations fails (which you'll find when bringing the script to other parts of the universe)

# Rerun with --snapshot-update; abort if this also fails
eval "${PYTEST_COMMAND} --snapshot-update" || {
echo ""
echo -e "${CFAIL}Pytest failed, not a snapshot issue ...${CNORM}"
exit 1
}
# Second run succeeded ⇒ mark snapshots updated
SNAPSHOT_UPDATED=1
} && {
echo ""
echo -e "${CINFO}Pytest / Snapshot validation passed"
}
fi # testing

if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "quality" ] ; then
Expand Down Expand Up @@ -284,6 +300,9 @@ if [ -z "${GITHUB_ACTIONS}" ]; then
echo ""
cp -r ./homeassistant/components/${REPO_NAME} ../custom_components/
cp -r ./tests/components/${REPO_NAME} ../tests/components/
if [ "${SNAPSHOT_UPDATED}" == "1" ]; then
echo -e "${CWARN}Note: updated snapshots ...${CNORM}"
fi
echo -e "${CINFO}Removing 'version' from manifest for hassfest-ing, version not allowed in core components${CNORM}"
echo ""
# shellcheck disable=SC2090
Expand Down
28 changes: 25 additions & 3 deletions tests/components/plugwise/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Setup mocks for the Plugwise integration tests."""
from __future__ import annotations

from collections.abc import Generator
from collections.abc import AsyncGenerator, Generator
import json
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch
Expand Down Expand Up @@ -125,6 +125,28 @@ def mock_smile_config_flow() -> Generator[MagicMock]:
yield api


@pytest.fixture
def platforms() -> list[str]:
"""Fixture for platforms."""
return []


@pytest.fixture
async def setup_platform(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
platforms,
) -> AsyncGenerator[None]:
"""Set up one or all platforms."""

mock_config_entry.add_to_hass(hass)

with patch(f"homeassistant.components.{DOMAIN}.PLATFORMS", platforms):
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
yield mock_config_entry


@pytest.fixture
def mock_smile_adam() -> Generator[MagicMock]:
"""Create a Mock Adam type for testing."""
Expand Down Expand Up @@ -187,8 +209,8 @@ def mock_smile_adam_heat_cool(chosen_env: str, cooling_present: bool) -> Generat


@pytest.fixture
def mock_smile_adam_4() -> Generator[MagicMock]:
"""Create a 4th Mock Adam type for testing."""
def mock_smile_adam_jip() -> Generator[MagicMock]:
"""Create a Mock Adam-Jip type for testing."""
chosen_env = "m_adam_jip"
data = _read_json(chosen_env, "data")
with patch(
Expand Down
Loading
Loading