Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases for ViCare entities #122983

Merged
merged 10 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add test case
  • Loading branch information
CFenner committed Jul 31, 2024
commit dd90216ad7333520a2c97c5bf7a241cd0b47d11a
11 changes: 11 additions & 0 deletions tests/components/vicare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

from homeassistant.components.vicare.const import CONF_HEATING_TYPE
from homeassistant.const import CONF_CLIENT_ID, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant

from tests.common import MockConfigEntry

MODULE = "homeassistant.components.vicare"

Expand All @@ -17,3 +20,11 @@
}

MOCK_MAC = "B874241B7B9"


async def setup_integration(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
"""Fixture for setting up the component."""
config_entry.add_to_hass(hass)

await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
22 changes: 17 additions & 5 deletions tests/components/vicare/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from homeassistant.components.vicare.const import DOMAIN
from homeassistant.core import HomeAssistant

from . import ENTRY_CONFIG, MODULE
from . import ENTRY_CONFIG, MODULE, setup_integration

from tests.common import MockConfigEntry, load_json_object_fixture

Expand All @@ -40,7 +40,7 @@ def __init__(self, fixtures: list[Fixture]) -> None:
),
f"deviceId{idx}",
f"model{idx}",
f"online{idx}",
"online",
)
)

Expand Down Expand Up @@ -87,10 +87,22 @@ async def mock_vicare_gas_boiler(
f"{MODULE}.vicare_login",
return_value=MockPyViCare(fixtures),
):
mock_config_entry.add_to_hass(hass)
await setup_integration(hass, mock_config_entry)

await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
yield mock_config_entry


@pytest.fixture
async def mock_vicare_fan(
Copy link
Member

Choose a reason for hiding this comment

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

Is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, seems not. I will remove it.

hass: HomeAssistant, mock_config_entry: MockConfigEntry
) -> AsyncGenerator[MockConfigEntry, None]:
"""Return a mocked ViCare API representing a single ventilation device."""
fixtures: list[Fixture] = [Fixture({"type:ventilation"}, "vicare/ViAir300F.json")]
with patch(
f"{MODULE}.vicare_login",
return_value=MockPyViCare(fixtures),
):
await setup_integration(hass, mock_config_entry)

yield mock_config_entry

Expand Down
Loading