mirror of
https://github.com/home-assistant/core.git
synced 2026-02-15 07:36:16 +00:00
Firefly III fix background task (#160935)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from pyfirefly.exceptions import (
|
||||
FireflyAuthenticationError,
|
||||
FireflyConnectionError,
|
||||
@@ -10,14 +11,16 @@ from pyfirefly.exceptions import (
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.firefly_iii.coordinator import DEFAULT_SCAN_INTERVAL
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
||||
|
||||
|
||||
async def test_all_entities(
|
||||
@@ -51,6 +54,7 @@ async def test_refresh_exceptions(
|
||||
mock_firefly_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
exception: Exception,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test entities go unavailable after coordinator refresh failures."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
@@ -58,7 +62,9 @@ async def test_refresh_exceptions(
|
||||
|
||||
mock_firefly_client.get_accounts.side_effect = exception
|
||||
|
||||
await mock_config_entry.runtime_data.async_refresh()
|
||||
freezer.tick(DEFAULT_SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass, dt_util.utcnow())
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
state = hass.states.get("sensor.credit_card_account_balance")
|
||||
assert state is not None
|
||||
|
||||
Reference in New Issue
Block a user