Skip to content

Commit

Permalink
Modify data update tests to not call coordinator internals
Browse files Browse the repository at this point in the history
  • Loading branch information
sdb9696 committed Nov 13, 2023
1 parent be075ac commit 7c7c1b7
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions tests/components/ring/test_init.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""The tests for the Ring component."""

from datetime import timedelta
from unittest.mock import patch

import pytest
Expand All @@ -11,8 +12,9 @@
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util

from tests.common import MockConfigEntry, load_fixture
from tests.common import MockConfigEntry, async_fire_time_changed, load_fixture


async def test_setup(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -> None:
Expand Down Expand Up @@ -78,9 +80,7 @@ async def test_auth_failure_on_global_update(
"ring_doorbell.Ring.update_devices",
side_effect=AuthenticationError,
):
await hass.data[DOMAIN][mock_config_entry.entry_id][
"device_data"
].async_refresh_all()
async_fire_time_changed(hass, dt_util.now() + timedelta(minutes=20))
await hass.async_block_till_done()

assert "Ring access token is no longer valid. Set up Ring again" in [
Expand All @@ -105,7 +105,7 @@ async def test_auth_failure_on_device_update(
"ring_doorbell.RingDoorBell.history",
side_effect=AuthenticationError,
):
hass.data[DOMAIN][mock_config_entry.entry_id]["history_data"].refresh_all()
async_fire_time_changed(hass, dt_util.now() + timedelta(minutes=20))
await hass.async_block_till_done()

assert "Ring access token is no longer valid. Set up Ring again" in [
Expand Down Expand Up @@ -146,9 +146,7 @@ async def test_error_on_global_update(
"ring_doorbell.Ring.update_devices",
side_effect=error_type,
):
await hass.data[DOMAIN][mock_config_entry.entry_id][
"device_data"
].async_refresh_all()
async_fire_time_changed(hass, dt_util.now() + timedelta(minutes=20))
await hass.async_block_till_done()

assert log_msg in [
Expand Down Expand Up @@ -189,7 +187,7 @@ async def test_error_on_device_update(
"ring_doorbell.RingDoorBell.history",
side_effect=error_type,
):
hass.data[DOMAIN][mock_config_entry.entry_id]["history_data"].refresh_all()
async_fire_time_changed(hass, dt_util.now() + timedelta(minutes=20))
await hass.async_block_till_done()

assert log_msg in [
Expand Down

0 comments on commit 7c7c1b7

Please sign in to comment.