mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Fix regex patterns in foobot sensor tests (#147306)
This commit is contained in:
parent
41e53297c2
commit
7d421bf223
@ -34,11 +34,11 @@ async def test_default_setup(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Test the default setup."""
|
"""Test the default setup."""
|
||||||
aioclient_mock.get(
|
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"),
|
text=await async_load_fixture(hass, "devices.json", "foobot"),
|
||||||
)
|
)
|
||||||
aioclient_mock.get(
|
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"),
|
text=await async_load_fixture(hass, "data.json", "foobot"),
|
||||||
)
|
)
|
||||||
assert await async_setup_component(hass, sensor.DOMAIN, {"sensor": VALID_CONFIG})
|
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."""
|
"""Expected failures caused by a timeout in API response."""
|
||||||
fake_async_add_entities = MagicMock()
|
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):
|
with pytest.raises(PlatformNotReady):
|
||||||
await foobot.async_setup_platform(hass, VALID_CONFIG, fake_async_add_entities)
|
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]
|
errors = [HTTPStatus.BAD_REQUEST, HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN]
|
||||||
for error in errors:
|
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(
|
result = await foobot.async_setup_platform(
|
||||||
hass, VALID_CONFIG, fake_async_add_entities
|
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]
|
errors = [HTTPStatus.TOO_MANY_REQUESTS, HTTPStatus.INTERNAL_SERVER_ERROR]
|
||||||
for error in errors:
|
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):
|
with pytest.raises(PlatformNotReady):
|
||||||
await foobot.async_setup_platform(
|
await foobot.async_setup_platform(
|
||||||
hass, VALID_CONFIG, fake_async_add_entities
|
hass, VALID_CONFIG, fake_async_add_entities
|
||||||
|
Loading…
x
Reference in New Issue
Block a user