mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Relocate Bluetooth manager to habluetooth library (#105110)
* Relocate Bluetooth manager to habluetooth library
* Relocate Bluetooth manager to habluetooth library
* Relocate Bluetooth manager to habluetooth library
* fixes
* fix patching time
* fix more tests
* fix more tests
* split
* Bump habluetooth to 0.7.0
changelog: https://github.com/Bluetooth-Devices/habluetooth/compare/v0.6.1...v0.7.0
This is the big change that will move the manager so the HA
PR that will follow this will be a bit larger than the rest of them
since the manager is connected to everything
* fix types
* fix types
* fix types
* fix patch targets
* fix flakey logbook tests (will need another PR)
* mock shutdown
* bump again
* value can be a float now
* Revert "value can be a float now"
This reverts commit b7e7127143.
* float
This commit is contained in:
@@ -7,6 +7,7 @@ from unittest.mock import patch
|
||||
|
||||
from bleak.backends.scanner import AdvertisementData, BLEDevice
|
||||
from bluetooth_adapters import AdvertisementHistory
|
||||
from habluetooth.manager import FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import bluetooth
|
||||
@@ -31,9 +32,6 @@ from homeassistant.components.bluetooth.const import (
|
||||
SOURCE_LOCAL,
|
||||
UNAVAILABLE_TRACK_SECONDS,
|
||||
)
|
||||
from homeassistant.components.bluetooth.manager import (
|
||||
FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
@@ -48,6 +46,7 @@ from . import (
|
||||
inject_advertisement_with_source,
|
||||
inject_advertisement_with_time_and_source,
|
||||
inject_advertisement_with_time_and_source_connectable,
|
||||
patch_bluetooth_time,
|
||||
)
|
||||
|
||||
from tests.common import async_fire_time_changed, load_fixture
|
||||
@@ -962,9 +961,8 @@ async def test_goes_unavailable_dismisses_discovery_and_makes_discoverable(
|
||||
return_value=[{"flow_id": "mock_flow_id"}],
|
||||
) as mock_async_progress_by_init_data_type, patch.object(
|
||||
hass.config_entries.flow, "async_abort"
|
||||
) as mock_async_abort, patch(
|
||||
"homeassistant.components.bluetooth.manager.MONOTONIC_TIME",
|
||||
return_value=monotonic_now + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
|
||||
) as mock_async_abort, patch_bluetooth_time(
|
||||
monotonic_now + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
|
||||
):
|
||||
async_fire_time_changed(
|
||||
hass, dt_util.utcnow() + timedelta(seconds=UNAVAILABLE_TRACK_SECONDS)
|
||||
@@ -1105,9 +1103,8 @@ async def test_set_fallback_interval_small(
|
||||
)
|
||||
|
||||
monotonic_now = start_monotonic_time + 2
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.manager.MONOTONIC_TIME",
|
||||
return_value=monotonic_now + UNAVAILABLE_TRACK_SECONDS,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now + UNAVAILABLE_TRACK_SECONDS,
|
||||
):
|
||||
async_fire_time_changed(
|
||||
hass, dt_util.utcnow() + timedelta(seconds=UNAVAILABLE_TRACK_SECONDS)
|
||||
@@ -1170,9 +1167,8 @@ async def test_set_fallback_interval_big(
|
||||
# Check that device hasn't expired after a day
|
||||
|
||||
monotonic_now = start_monotonic_time + 86400
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.manager.MONOTONIC_TIME",
|
||||
return_value=monotonic_now + UNAVAILABLE_TRACK_SECONDS,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now + UNAVAILABLE_TRACK_SECONDS,
|
||||
):
|
||||
async_fire_time_changed(
|
||||
hass, dt_util.utcnow() + timedelta(seconds=UNAVAILABLE_TRACK_SECONDS)
|
||||
@@ -1184,9 +1180,8 @@ async def test_set_fallback_interval_big(
|
||||
# Try again after it has expired
|
||||
|
||||
monotonic_now = start_monotonic_time + 604800
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.manager.MONOTONIC_TIME",
|
||||
return_value=monotonic_now + UNAVAILABLE_TRACK_SECONDS,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now + UNAVAILABLE_TRACK_SECONDS,
|
||||
):
|
||||
async_fire_time_changed(
|
||||
hass, dt_util.utcnow() + timedelta(seconds=UNAVAILABLE_TRACK_SECONDS)
|
||||
|
||||
Reference in New Issue
Block a user