mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 22:55:10 +02:00
fix more tests
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"""Test the Govee BLE sensors."""
|
||||
from datetime import timedelta
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.bluetooth import (
|
||||
FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
|
||||
@@ -27,6 +26,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
from tests.components.bluetooth import (
|
||||
inject_bluetooth_service_info,
|
||||
patch_all_discovered_devices,
|
||||
patch_bluetooth_time,
|
||||
)
|
||||
|
||||
|
||||
@@ -112,9 +112,8 @@ async def test_gvh5178_multi_sensor(hass: HomeAssistant) -> None:
|
||||
# Fastforward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
@@ -139,9 +138,8 @@ async def test_gvh5178_multi_sensor(hass: HomeAssistant) -> None:
|
||||
assert primary_temp_sensor.state == "1.0"
|
||||
|
||||
# Fastforward time without BLE advertisements
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
from datetime import timedelta
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.bluetooth import (
|
||||
FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
|
||||
@@ -24,6 +23,7 @@ from tests.components.bluetooth import (
|
||||
inject_bluetooth_service_info,
|
||||
inject_bluetooth_service_info_bleak,
|
||||
patch_all_discovered_devices,
|
||||
patch_bluetooth_time,
|
||||
)
|
||||
|
||||
|
||||
@@ -63,9 +63,8 @@ async def test_sensors(
|
||||
# Fastforward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
@@ -114,9 +113,8 @@ async def test_sensors_io_series_4(
|
||||
# Fast-forward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
from datetime import timedelta
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
from home_assistant_bluetooth import BluetoothServiceInfoBleak
|
||||
|
||||
@@ -16,6 +15,7 @@ from tests.components.bluetooth import (
|
||||
generate_advertisement_data,
|
||||
generate_ble_device,
|
||||
inject_bluetooth_service_info_bleak,
|
||||
patch_bluetooth_time,
|
||||
)
|
||||
|
||||
MAC_RPA_VALID_1 = "40:01:02:0a:c4:a6"
|
||||
@@ -70,9 +70,8 @@ async def async_inject_broadcast(
|
||||
|
||||
async def async_move_time_forwards(hass: HomeAssistant, offset: float):
|
||||
"""Mock time advancing from now to now+offset."""
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=time.monotonic() + offset,
|
||||
with patch_bluetooth_time(
|
||||
time.monotonic() + offset,
|
||||
):
|
||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=offset))
|
||||
await hass.async_block_till_done()
|
||||
|
@@ -1,7 +1,6 @@
|
||||
"""Test the Qingping binary sensors."""
|
||||
from datetime import timedelta
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.bluetooth import (
|
||||
FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
|
||||
@@ -17,6 +16,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
from tests.components.bluetooth import (
|
||||
inject_bluetooth_service_info,
|
||||
patch_all_discovered_devices,
|
||||
patch_bluetooth_time,
|
||||
)
|
||||
|
||||
|
||||
@@ -72,9 +72,8 @@ async def test_binary_sensor_restore_state(hass: HomeAssistant) -> None:
|
||||
# Fastforward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
|
@@ -1,7 +1,6 @@
|
||||
"""Test the Qingping sensors."""
|
||||
from datetime import timedelta
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.bluetooth import (
|
||||
FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
|
||||
@@ -22,6 +21,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
from tests.components.bluetooth import (
|
||||
inject_bluetooth_service_info,
|
||||
patch_all_discovered_devices,
|
||||
patch_bluetooth_time,
|
||||
)
|
||||
|
||||
|
||||
@@ -82,9 +82,8 @@ async def test_binary_sensor_restore_state(hass: HomeAssistant) -> None:
|
||||
# Fastforward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
|
@@ -1,7 +1,6 @@
|
||||
"""Test the SensorPush sensors."""
|
||||
from datetime import timedelta
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.bluetooth import (
|
||||
FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
|
||||
@@ -22,6 +21,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
from tests.components.bluetooth import (
|
||||
inject_bluetooth_service_info,
|
||||
patch_all_discovered_devices,
|
||||
patch_bluetooth_time,
|
||||
)
|
||||
|
||||
|
||||
@@ -55,9 +55,8 @@ async def test_sensors(hass: HomeAssistant) -> None:
|
||||
# Fastforward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
from datetime import timedelta
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.bluetooth import (
|
||||
FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
|
||||
@@ -23,6 +22,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
from tests.components.bluetooth import (
|
||||
inject_bluetooth_service_info_bleak,
|
||||
patch_all_discovered_devices,
|
||||
patch_bluetooth_time,
|
||||
)
|
||||
|
||||
|
||||
@@ -294,9 +294,8 @@ async def test_unavailable(hass: HomeAssistant) -> None:
|
||||
# Fastforward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
@@ -347,9 +346,8 @@ async def test_sleepy_device(hass: HomeAssistant) -> None:
|
||||
# Fastforward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
@@ -400,9 +398,8 @@ async def test_sleepy_device_restore_state(hass: HomeAssistant) -> None:
|
||||
# Fastforward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
|
@@ -1,7 +1,6 @@
|
||||
"""Test Xiaomi BLE sensors."""
|
||||
from datetime import timedelta
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.bluetooth import (
|
||||
FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS,
|
||||
@@ -28,6 +27,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
from tests.components.bluetooth import (
|
||||
inject_bluetooth_service_info_bleak,
|
||||
patch_all_discovered_devices,
|
||||
patch_bluetooth_time,
|
||||
)
|
||||
|
||||
|
||||
@@ -692,9 +692,8 @@ async def test_unavailable(hass: HomeAssistant) -> None:
|
||||
# Fastforward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
@@ -739,9 +738,8 @@ async def test_sleepy_device(hass: HomeAssistant) -> None:
|
||||
# Fastforward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
@@ -788,9 +786,8 @@ async def test_sleepy_device_restore_state(hass: HomeAssistant) -> None:
|
||||
# Fastforward time without BLE advertisements
|
||||
monotonic_now = start_monotonic + FALLBACK_MAXIMUM_STALE_ADVERTISEMENT_SECONDS + 1
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.bluetooth.MONOTONIC_TIME",
|
||||
return_value=monotonic_now,
|
||||
with patch_bluetooth_time(
|
||||
monotonic_now,
|
||||
), patch_all_discovered_devices([]):
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
|
Reference in New Issue
Block a user