Skip to content

Commit

Permalink
fix tests?
Browse files Browse the repository at this point in the history
  • Loading branch information
Lash-L committed Nov 2, 2024
1 parent 4b605eb commit d2e2aa4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from unittest.mock import patch
from homeassistant.config_entries import ConfigEntryState

import pytest
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -99,5 +100,5 @@ async def setup_bermuda_entry(hass: HomeAssistant):
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test", title=NAME)
config_entry.add_to_hass(hass)
await async_setup_component(hass, DOMAIN, {})
assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN]
assert config_entry.state == ConfigEntryState.LOADED
return config_entry
7 changes: 3 additions & 4 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from custom_components.bermuda.coordinator import BermudaDataUpdateCoordinator

from .const import MOCK_CONFIG
from homeassistant.config_entries import ConfigEntryState

# from pytest_homeassistant_custom_component.common import AsyncMock

Expand All @@ -24,16 +25,14 @@ async def test_setup_unload_and_reload_entry(
hass: HomeAssistant, bypass_get_data, setup_bermuda_entry: MockConfigEntry
):
"""Test entry setup and unload."""
assert isinstance(hass.data[DOMAIN][setup_bermuda_entry.entry_id], BermudaDataUpdateCoordinator)

# Reload the entry and assert that the data from above is still there
assert await hass.config_entries.async_reload(setup_bermuda_entry.entry_id)

Check failure on line 30 in tests/test_init.py

View workflow job for this annotation

GitHub Actions / Run tests

test_setup_unload_and_reload_entry assert False
assert DOMAIN in hass.data and setup_bermuda_entry.entry_id in hass.data[DOMAIN]
assert isinstance(hass.data[DOMAIN][setup_bermuda_entry.entry_id], BermudaDataUpdateCoordinator)
assert setup_bermuda_entry.state == ConfigEntryState.LOADED

# Unload the entry and verify that the data has been removed
assert await hass.config_entries.async_unload(setup_bermuda_entry.entry_id)
assert setup_bermuda_entry.entry_id not in hass.data[DOMAIN]
assert setup_bermuda_entry.entry_id == ConfigEntryState.NOT_LOADED


async def test_setup_entry_exception(hass, error_on_get_data):
Expand Down

0 comments on commit d2e2aa4

Please sign in to comment.