@@ -255,6 +255,96 @@ async def test_form_invalid_auth_cloud(
255255 assert result ["errors" ] == {"base" : error }
256256
257257
258+ @pytest .mark .parametrize (
259+ ("side_effect" , "description_placeholder" , "server" ),
260+ [
261+ (UnknownUserException , "CozyTouch" , TEST_SERVER_COZYTOUCH ),
262+ (UnknownUserException , "Unknown" , TEST_SERVER2 ),
263+ ],
264+ )
265+ async def test_form_invalid_hardware_cloud (
266+ hass : HomeAssistant ,
267+ side_effect : Exception ,
268+ description_placeholder : str ,
269+ server : str ,
270+ ) -> None :
271+ """Test we handle unsupported hardware (cloud)."""
272+ result = await hass .config_entries .flow .async_init (
273+ DOMAIN , context = {"source" : config_entries .SOURCE_USER }
274+ )
275+
276+ assert result ["type" ] is FlowResultType .FORM
277+
278+ result = await hass .config_entries .flow .async_configure (
279+ result ["flow_id" ],
280+ {"hub" : server },
281+ )
282+
283+ assert result ["type" ] is FlowResultType .FORM
284+ assert result ["step_id" ] == "cloud"
285+
286+ with patch ("pyoverkiz.client.OverkizClient.login" , side_effect = side_effect ):
287+ result = await hass .config_entries .flow .async_configure (
288+ result ["flow_id" ],
289+ {"username" : TEST_EMAIL , "password" : TEST_PASSWORD },
290+ )
291+
292+ await hass .async_block_till_done ()
293+
294+ assert result ["type" ] is FlowResultType .FORM
295+ assert result ["errors" ] == {"base" : "unsupported_hardware" }
296+ assert result ["description_placeholders" ] == {
297+ "unsupported_device" : description_placeholder
298+ }
299+
300+
301+ @pytest .mark .parametrize (
302+ ("side_effect" , "description_placeholder" , "server" ),
303+ [
304+ (UnknownUserException , "Somfy Protect" , TEST_SERVER ),
305+ ],
306+ )
307+ async def test_form_invalid_hardware_cloud_local (
308+ hass : HomeAssistant ,
309+ side_effect : Exception ,
310+ description_placeholder : str ,
311+ server : str ,
312+ ) -> None :
313+ """Test we handle unsupported hardware (cloud and local)."""
314+ result = await hass .config_entries .flow .async_init (
315+ DOMAIN , context = {"source" : config_entries .SOURCE_USER }
316+ )
317+
318+ assert result ["type" ] is FlowResultType .FORM
319+
320+ result = await hass .config_entries .flow .async_configure (
321+ result ["flow_id" ],
322+ {"hub" : server },
323+ )
324+
325+ result = await hass .config_entries .flow .async_configure (
326+ result ["flow_id" ],
327+ {"api_type" : "cloud" },
328+ )
329+
330+ assert result ["type" ] is FlowResultType .FORM
331+ assert result ["step_id" ] == "cloud"
332+
333+ with patch ("pyoverkiz.client.OverkizClient.login" , side_effect = side_effect ):
334+ result = await hass .config_entries .flow .async_configure (
335+ result ["flow_id" ],
336+ {"username" : TEST_EMAIL , "password" : TEST_PASSWORD },
337+ )
338+
339+ await hass .async_block_till_done ()
340+
341+ assert result ["type" ] is FlowResultType .FORM
342+ assert result ["errors" ] == {"base" : "unsupported_hardware" }
343+ assert result ["description_placeholders" ] == {
344+ "unsupported_device" : description_placeholder
345+ }
346+
347+
258348@pytest .mark .parametrize (
259349 ("side_effect" , "error" ),
260350 [
0 commit comments