Fix regex patterns in foobot sensor tests (#147306)

This commit is contained in:
Michael 2025-06-22 19:02:43 +02:00 committed by GitHub
parent 41e53297c2
commit 7d421bf223
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,11 +34,11 @@ async def test_default_setup(
) -> None:
"""Test the default setup."""
aioclient_mock.get(
re.compile("api.foobot.io/v2/owner/.*"),
re.compile(r"api\.foobot\.io/v2/owner/.*"),
text=await async_load_fixture(hass, "devices.json", "foobot"),
)
aioclient_mock.get(
re.compile("api.foobot.io/v2/device/.*"),
re.compile(r"api\.foobot\.io/v2/device/.*"),
text=await async_load_fixture(hass, "data.json", "foobot"),
)
assert await async_setup_component(hass, sensor.DOMAIN, {"sensor": VALID_CONFIG})
@ -65,7 +65,7 @@ async def test_setup_timeout_error(
"""Expected failures caused by a timeout in API response."""
fake_async_add_entities = MagicMock()
aioclient_mock.get(re.compile("api.foobot.io/v2/owner/.*"), exc=TimeoutError())
aioclient_mock.get(re.compile(r"api\.foobot\.io/v2/owner/.*"), exc=TimeoutError())
with pytest.raises(PlatformNotReady):
await foobot.async_setup_platform(hass, VALID_CONFIG, fake_async_add_entities)
@ -78,7 +78,7 @@ async def test_setup_permanent_error(
errors = [HTTPStatus.BAD_REQUEST, HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN]
for error in errors:
aioclient_mock.get(re.compile("api.foobot.io/v2/owner/.*"), status=error)
aioclient_mock.get(re.compile(r"api\.foobot\.io/v2/owner/.*"), status=error)
result = await foobot.async_setup_platform(
hass, VALID_CONFIG, fake_async_add_entities
)
@ -93,7 +93,7 @@ async def test_setup_temporary_error(
errors = [HTTPStatus.TOO_MANY_REQUESTS, HTTPStatus.INTERNAL_SERVER_ERROR]
for error in errors:
aioclient_mock.get(re.compile("api.foobot.io/v2/owner/.*"), status=error)
aioclient_mock.get(re.compile(r"api\.foobot\.io/v2/owner/.*"), status=error)
with pytest.raises(PlatformNotReady):
await foobot.async_setup_platform(
hass, VALID_CONFIG, fake_async_add_entities