Use common variables in platform tests for UptimeRobot (#154909)

This commit is contained in:
Simone Chemelli
2025-10-21 08:12:09 +02:00
committed by GitHub
parent 080b16a33d
commit b078c0ee7e
4 changed files with 16 additions and 43 deletions
+7 -1
View File
@@ -47,7 +47,13 @@ MOCK_UPTIMEROBOT_MONITOR_PAUSED = {
"type": 1,
"url": "http://example.com",
}
MOCK_UPTIMEROBOT_MONITOR_2 = {
"id": 5678,
"friendly_name": "Test monitor 2",
"status": 2,
"type": 1,
"url": "http://example2.com",
}
MOCK_UPTIMEROBOT_CONFIG_ENTRY_DATA = {
"domain": DOMAIN,
@@ -15,6 +15,7 @@ from homeassistant.util import dt as dt_util
from .common import (
MOCK_UPTIMEROBOT_MONITOR,
MOCK_UPTIMEROBOT_MONITOR_2,
UPTIMEROBOT_BINARY_SENSOR_TEST_ENTITY,
mock_uptimerobot_api_response,
setup_uptimerobot_integration,
@@ -65,20 +66,8 @@ async def test_binary_sensor_dynamic(hass: HomeAssistant) -> None:
"pyuptimerobot.UptimeRobot.async_get_monitors",
return_value=mock_uptimerobot_api_response(
data=[
{
"id": 1234,
"friendly_name": "Test monitor",
"status": 2,
"type": 1,
"url": "http://example.com",
},
{
"id": 5678,
"friendly_name": "Test monitor 2",
"status": 2,
"type": 1,
"url": "http://example2.com",
},
MOCK_UPTIMEROBOT_MONITOR,
MOCK_UPTIMEROBOT_MONITOR_2,
]
),
):
+3 -14
View File
@@ -12,6 +12,7 @@ from homeassistant.util import dt as dt_util
from .common import (
MOCK_UPTIMEROBOT_MONITOR,
MOCK_UPTIMEROBOT_MONITOR_2,
STATE_UP,
UPTIMEROBOT_SENSOR_TEST_ENTITY,
mock_uptimerobot_api_response,
@@ -69,20 +70,8 @@ async def test_sensor_dynamic(hass: HomeAssistant) -> None:
"pyuptimerobot.UptimeRobot.async_get_monitors",
return_value=mock_uptimerobot_api_response(
data=[
{
"id": 1234,
"friendly_name": "Test monitor",
"status": 2,
"type": 1,
"url": "http://example.com",
},
{
"id": 5678,
"friendly_name": "Test monitor 2",
"status": 2,
"type": 1,
"url": "http://example2.com",
},
MOCK_UPTIMEROBOT_MONITOR,
MOCK_UPTIMEROBOT_MONITOR_2,
]
),
):
+3 -14
View File
@@ -21,6 +21,7 @@ from homeassistant.util import dt as dt_util
from .common import (
MOCK_UPTIMEROBOT_CONFIG_ENTRY_DATA,
MOCK_UPTIMEROBOT_MONITOR,
MOCK_UPTIMEROBOT_MONITOR_2,
MOCK_UPTIMEROBOT_MONITOR_PAUSED,
UPTIMEROBOT_SWITCH_TEST_ENTITY,
MockApiResponseKey,
@@ -197,20 +198,8 @@ async def test_switch_dynamic(hass: HomeAssistant) -> None:
"pyuptimerobot.UptimeRobot.async_get_monitors",
return_value=mock_uptimerobot_api_response(
data=[
{
"id": 1234,
"friendly_name": "Test monitor",
"status": 2,
"type": 1,
"url": "http://example.com",
},
{
"id": 5678,
"friendly_name": "Test monitor 2",
"status": 2,
"type": 1,
"url": "http://example2.com",
},
MOCK_UPTIMEROBOT_MONITOR,
MOCK_UPTIMEROBOT_MONITOR_2,
]
),
):