Skip to content

Commit

Permalink
Fix CI failure due to integrations leaving dirty known_devices.yaml (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
thecode authored and balloob committed Jul 8, 2022
1 parent 14c6b8d commit a3abe74
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
13 changes: 5 additions & 8 deletions tests/components/demo/test_init.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""The tests for the Demo component."""
from contextlib import suppress
import json
import os
from unittest.mock import patch

import pytest

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.statistics import list_statistic_ids
from homeassistant.helpers.json import JSONEncoder
Expand All @@ -22,11 +20,10 @@ def mock_history(hass):


@pytest.fixture(autouse=True)
def demo_cleanup(hass):
"""Clean up device tracker demo file."""
yield
with suppress(FileNotFoundError):
os.remove(hass.config.path(YAML_DEVICES))
def mock_device_tracker_update_config(hass):
"""Prevent device tracker from creating known devices file."""
with patch("homeassistant.components.device_tracker.legacy.update_config"):
yield


async def test_setting_up_demo(hass):
Expand Down
13 changes: 8 additions & 5 deletions tests/components/device_tracker/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util

from . import common

from tests.common import (
assert_setup_component,
async_fire_time_changed,
mock_registry,
mock_restore_cache,
patch_yaml_files,
)
from tests.components.device_tracker import common

TEST_PLATFORM = {device_tracker.DOMAIN: {CONF_PLATFORM: "test"}}

Expand Down Expand Up @@ -165,6 +166,7 @@ async def test_setup_without_yaml_file(hass, enable_custom_integrations):
"""Test with no YAML file."""
with assert_setup_component(1, device_tracker.DOMAIN):
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
await hass.async_block_till_done()


async def test_gravatar(hass):
Expand Down Expand Up @@ -210,10 +212,11 @@ async def test_gravatar_and_picture(hass):
@patch("homeassistant.components.demo.device_tracker.setup_scanner", autospec=True)
async def test_discover_platform(mock_demo_setup_scanner, mock_see, hass):
"""Test discovery of device_tracker demo platform."""
await discovery.async_load_platform(
hass, device_tracker.DOMAIN, "demo", {"test_key": "test_val"}, {"bla": {}}
)
await hass.async_block_till_done()
with patch("homeassistant.components.device_tracker.legacy.update_config"):
await discovery.async_load_platform(
hass, device_tracker.DOMAIN, "demo", {"test_key": "test_val"}, {"bla": {}}
)
await hass.async_block_till_done()
assert device_tracker.DOMAIN in hass.config.components
assert mock_demo_setup_scanner.called
assert mock_demo_setup_scanner.call_args[0] == (
Expand Down

0 comments on commit a3abe74

Please sign in to comment.