Fix CI failure due to integrations leaving dirty known_devices.yaml (#74329)
This commit is contained in:
parent
64bfa20f6a
commit
d56a487169
2 changed files with 13 additions and 13 deletions
|
@ -1,12 +1,10 @@
|
||||||
"""The tests for the Demo component."""
|
"""The tests for the Demo component."""
|
||||||
from contextlib import suppress
|
|
||||||
import json
|
import json
|
||||||
import os
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.demo import DOMAIN
|
from homeassistant.components.demo import DOMAIN
|
||||||
from homeassistant.components.device_tracker.legacy import YAML_DEVICES
|
|
||||||
from homeassistant.components.recorder import get_instance
|
from homeassistant.components.recorder import get_instance
|
||||||
from homeassistant.components.recorder.statistics import list_statistic_ids
|
from homeassistant.components.recorder.statistics import list_statistic_ids
|
||||||
from homeassistant.helpers.json import JSONEncoder
|
from homeassistant.helpers.json import JSONEncoder
|
||||||
|
@ -22,11 +20,10 @@ def mock_history(hass):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def demo_cleanup(hass):
|
def mock_device_tracker_update_config(hass):
|
||||||
"""Clean up device tracker demo file."""
|
"""Prevent device tracker from creating known devices file."""
|
||||||
|
with patch("homeassistant.components.device_tracker.legacy.update_config"):
|
||||||
yield
|
yield
|
||||||
with suppress(FileNotFoundError):
|
|
||||||
os.remove(hass.config.path(YAML_DEVICES))
|
|
||||||
|
|
||||||
|
|
||||||
async def test_setting_up_demo(hass):
|
async def test_setting_up_demo(hass):
|
||||||
|
|
|
@ -28,6 +28,8 @@ from homeassistant.helpers.json import JSONEncoder
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
|
from . import common
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
assert_setup_component,
|
assert_setup_component,
|
||||||
async_fire_time_changed,
|
async_fire_time_changed,
|
||||||
|
@ -35,7 +37,6 @@ from tests.common import (
|
||||||
mock_restore_cache,
|
mock_restore_cache,
|
||||||
patch_yaml_files,
|
patch_yaml_files,
|
||||||
)
|
)
|
||||||
from tests.components.device_tracker import common
|
|
||||||
|
|
||||||
TEST_PLATFORM = {device_tracker.DOMAIN: {CONF_PLATFORM: "test"}}
|
TEST_PLATFORM = {device_tracker.DOMAIN: {CONF_PLATFORM: "test"}}
|
||||||
|
|
||||||
|
@ -165,6 +166,7 @@ async def test_setup_without_yaml_file(hass, enable_custom_integrations):
|
||||||
"""Test with no YAML file."""
|
"""Test with no YAML file."""
|
||||||
with assert_setup_component(1, device_tracker.DOMAIN):
|
with assert_setup_component(1, device_tracker.DOMAIN):
|
||||||
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
|
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
async def test_gravatar(hass):
|
async def test_gravatar(hass):
|
||||||
|
@ -210,6 +212,7 @@ async def test_gravatar_and_picture(hass):
|
||||||
@patch("homeassistant.components.demo.device_tracker.setup_scanner", autospec=True)
|
@patch("homeassistant.components.demo.device_tracker.setup_scanner", autospec=True)
|
||||||
async def test_discover_platform(mock_demo_setup_scanner, mock_see, hass):
|
async def test_discover_platform(mock_demo_setup_scanner, mock_see, hass):
|
||||||
"""Test discovery of device_tracker demo platform."""
|
"""Test discovery of device_tracker demo platform."""
|
||||||
|
with patch("homeassistant.components.device_tracker.legacy.update_config"):
|
||||||
await discovery.async_load_platform(
|
await discovery.async_load_platform(
|
||||||
hass, device_tracker.DOMAIN, "demo", {"test_key": "test_val"}, {"bla": {}}
|
hass, device_tracker.DOMAIN, "demo", {"test_key": "test_val"}, {"bla": {}}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue