Skip to content

Commit 4950bda

Browse files
authored
Fix homeaticip_cloud RuntimeWarnings (#142961)
1 parent 9e9be60 commit 4950bda

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

tests/components/homematicip_cloud/test_hap.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,24 @@ async def test_hap_reset_unloads_entry_if_setup(
129129
assert hass.data[HMIPC_DOMAIN] == {}
130130

131131

132-
@patch(
133-
"homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async",
134-
return_value=ConnectionContext(),
135-
)
136132
async def test_hap_create(
137133
hass: HomeAssistant, hmip_config_entry: MockConfigEntry, simple_mock_home
138134
) -> None:
139135
"""Mock AsyncHome to execute get_hap."""
140136
hass.config.components.add(HMIPC_DOMAIN)
141137
hap = HomematicipHAP(hass, hmip_config_entry)
142138
assert hap
143-
with patch.object(hap, "async_connect"):
139+
with (
140+
patch(
141+
"homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async",
142+
return_value=ConnectionContext(),
143+
),
144+
patch.object(hap, "async_connect"),
145+
):
144146
async with hmip_config_entry.setup_lock:
145147
assert await hap.async_setup()
146148

147149

148-
@patch(
149-
"homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async",
150-
return_value=ConnectionContext(),
151-
)
152150
async def test_hap_create_exception(
153151
hass: HomeAssistant, hmip_config_entry: MockConfigEntry, mock_connection_init
154152
) -> None:
@@ -158,13 +156,23 @@ async def test_hap_create_exception(
158156
hap = HomematicipHAP(hass, hmip_config_entry)
159157
assert hap
160158

161-
with patch(
162-
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state_async",
163-
side_effect=Exception,
159+
with (
160+
patch(
161+
"homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async",
162+
return_value=ConnectionContext(),
163+
),
164+
patch(
165+
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state_async",
166+
side_effect=Exception,
167+
),
164168
):
165169
assert not await hap.async_setup()
166170

167171
with (
172+
patch(
173+
"homeassistant.components.homematicip_cloud.hap.ConnectionContextBuilder.build_context_async",
174+
return_value=ConnectionContext(),
175+
),
168176
patch(
169177
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state_async",
170178
side_effect=HmipConnectionError,

0 commit comments

Comments
 (0)