Skip to content

Commit b078c0e

Browse files
authored
Use common variables in platform tests for UptimeRobot (home-assistant#154909)
1 parent 080b16a commit b078c0e

File tree

4 files changed

+16
-43
lines changed

4 files changed

+16
-43
lines changed

tests/components/uptimerobot/common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@
4747
"type": 1,
4848
"url": "http://example.com",
4949
}
50-
50+
MOCK_UPTIMEROBOT_MONITOR_2 = {
51+
"id": 5678,
52+
"friendly_name": "Test monitor 2",
53+
"status": 2,
54+
"type": 1,
55+
"url": "http://example2.com",
56+
}
5157

5258
MOCK_UPTIMEROBOT_CONFIG_ENTRY_DATA = {
5359
"domain": DOMAIN,

tests/components/uptimerobot/test_binary_sensor.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from .common import (
1717
MOCK_UPTIMEROBOT_MONITOR,
18+
MOCK_UPTIMEROBOT_MONITOR_2,
1819
UPTIMEROBOT_BINARY_SENSOR_TEST_ENTITY,
1920
mock_uptimerobot_api_response,
2021
setup_uptimerobot_integration,
@@ -65,20 +66,8 @@ async def test_binary_sensor_dynamic(hass: HomeAssistant) -> None:
6566
"pyuptimerobot.UptimeRobot.async_get_monitors",
6667
return_value=mock_uptimerobot_api_response(
6768
data=[
68-
{
69-
"id": 1234,
70-
"friendly_name": "Test monitor",
71-
"status": 2,
72-
"type": 1,
73-
"url": "http://example.com",
74-
},
75-
{
76-
"id": 5678,
77-
"friendly_name": "Test monitor 2",
78-
"status": 2,
79-
"type": 1,
80-
"url": "http://example2.com",
81-
},
69+
MOCK_UPTIMEROBOT_MONITOR,
70+
MOCK_UPTIMEROBOT_MONITOR_2,
8271
]
8372
),
8473
):

tests/components/uptimerobot/test_sensor.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from .common import (
1414
MOCK_UPTIMEROBOT_MONITOR,
15+
MOCK_UPTIMEROBOT_MONITOR_2,
1516
STATE_UP,
1617
UPTIMEROBOT_SENSOR_TEST_ENTITY,
1718
mock_uptimerobot_api_response,
@@ -69,20 +70,8 @@ async def test_sensor_dynamic(hass: HomeAssistant) -> None:
6970
"pyuptimerobot.UptimeRobot.async_get_monitors",
7071
return_value=mock_uptimerobot_api_response(
7172
data=[
72-
{
73-
"id": 1234,
74-
"friendly_name": "Test monitor",
75-
"status": 2,
76-
"type": 1,
77-
"url": "http://example.com",
78-
},
79-
{
80-
"id": 5678,
81-
"friendly_name": "Test monitor 2",
82-
"status": 2,
83-
"type": 1,
84-
"url": "http://example2.com",
85-
},
73+
MOCK_UPTIMEROBOT_MONITOR,
74+
MOCK_UPTIMEROBOT_MONITOR_2,
8675
]
8776
),
8877
):

tests/components/uptimerobot/test_switch.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .common import (
2222
MOCK_UPTIMEROBOT_CONFIG_ENTRY_DATA,
2323
MOCK_UPTIMEROBOT_MONITOR,
24+
MOCK_UPTIMEROBOT_MONITOR_2,
2425
MOCK_UPTIMEROBOT_MONITOR_PAUSED,
2526
UPTIMEROBOT_SWITCH_TEST_ENTITY,
2627
MockApiResponseKey,
@@ -197,20 +198,8 @@ async def test_switch_dynamic(hass: HomeAssistant) -> None:
197198
"pyuptimerobot.UptimeRobot.async_get_monitors",
198199
return_value=mock_uptimerobot_api_response(
199200
data=[
200-
{
201-
"id": 1234,
202-
"friendly_name": "Test monitor",
203-
"status": 2,
204-
"type": 1,
205-
"url": "http://example.com",
206-
},
207-
{
208-
"id": 5678,
209-
"friendly_name": "Test monitor 2",
210-
"status": 2,
211-
"type": 1,
212-
"url": "http://example2.com",
213-
},
201+
MOCK_UPTIMEROBOT_MONITOR,
202+
MOCK_UPTIMEROBOT_MONITOR_2,
214203
]
215204
),
216205
):

0 commit comments

Comments
 (0)