1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Restore history from bluetooth stack at startup (#78612)

This commit is contained in:
J. Nick Koston
2022-09-17 16:58:19 -05:00
committed by GitHub
parent 13d3f4c3b2
commit 18eef5da1f
16 changed files with 151 additions and 55 deletions

View File

@@ -1,10 +1,20 @@
"""Tests for the bluetooth component."""
from unittest.mock import patch
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
@pytest.fixture(name="bluez_dbus_mock")
def bluez_dbus_mock():
"""Fixture that mocks out the bluez dbus calls."""
# Must patch directly since this is loaded on demand only
with patch(
"bluetooth_adapters.BlueZDBusObjects", return_value=MagicMock(load=AsyncMock())
):
yield
@pytest.fixture(name="macos_adapter")
def macos_adapter():
"""Fixture that mocks the macos adapter."""
@@ -25,7 +35,7 @@ def windows_adapter():
@pytest.fixture(name="one_adapter")
def one_adapter_fixture():
def one_adapter_fixture(bluez_dbus_mock):
"""Fixture that mocks one adapter on Linux."""
with patch(
"homeassistant.components.bluetooth.platform.system", return_value="Linux"
@@ -54,7 +64,7 @@ def one_adapter_fixture():
@pytest.fixture(name="two_adapters")
def two_adapters_fixture():
def two_adapters_fixture(bluez_dbus_mock):
"""Fixture that mocks two adapters on Linux."""
with patch(
"homeassistant.components.bluetooth.platform.system", return_value="Linux"