Skip to content
Open
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
21 changes: 19 additions & 2 deletions scripts/core-testing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,22 @@ 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}"
eval "${PYTEST_COMMAND} --snapshot-update" || {
echo ""
echo -e "${CFAIL}Pytest failed, not a snapshot issue ...${CNORM}" || exit 1
} && {
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 +298,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
24 changes: 23 additions & 1 deletion 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
Loading
Loading