@@ -225,7 +225,7 @@ async def test_execute_returns_stdout(self, hass: HomeAssistant) -> None:
225225 mock_conn = _make_mock_conn (stdout = "hello\n " , stderr = "" , exit_status = 0 )
226226 with patch ("custom_components.ssh_command.coordinator.connect" ,
227227 return_value = _MockConnect (mock_conn )):
228- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
228+ with patch ("pathlib.Path .exists" , return_value = False ):
229229 result = await hass .services .async_call (
230230 DOMAIN ,
231231 SERVICE_EXECUTE ,
@@ -245,7 +245,7 @@ async def test_execute_returns_stderr(self, hass: HomeAssistant) -> None:
245245 mock_conn = _make_mock_conn (stdout = "" , stderr = "some error" , exit_status = 1 )
246246 with patch ("custom_components.ssh_command.coordinator.connect" ,
247247 return_value = _MockConnect (mock_conn )):
248- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
248+ with patch ("pathlib.Path .exists" , return_value = False ):
249249 result = await hass .services .async_call (
250250 DOMAIN ,
251251 SERVICE_EXECUTE ,
@@ -265,7 +265,7 @@ async def test_execute_with_password_auth(self, hass: HomeAssistant) -> None:
265265 data = {** SERVICE_DATA_BASE , "password" : "mysecret" }
266266 with patch ("custom_components.ssh_command.coordinator.connect" ,
267267 return_value = _MockConnect (mock_conn )) as mock_connect :
268- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
268+ with patch ("pathlib.Path .exists" , return_value = False ):
269269 await hass .services .async_call (
270270 DOMAIN ,
271271 SERVICE_EXECUTE ,
@@ -291,15 +291,14 @@ async def test_execute_with_key_file_auth(self, hass: HomeAssistant) -> None:
291291 }
292292 with patch ("custom_components.ssh_command.coordinator.connect" ,
293293 return_value = _MockConnect (mock_conn )) as mock_connect :
294- with patch ("custom_components.ssh_command.coordinator.exists" , return_value = True ):
295- with patch ("custom_components.ssh_command.exists" , return_value = True ):
296- await hass .services .async_call (
297- DOMAIN ,
298- SERVICE_EXECUTE ,
299- data ,
300- blocking = True ,
301- return_response = True ,
302- )
294+ with patch ("pathlib.Path.exists" , return_value = True ):
295+ await hass .services .async_call (
296+ DOMAIN ,
297+ SERVICE_EXECUTE ,
298+ data ,
299+ blocking = True ,
300+ return_response = True ,
301+ )
303302
304303 call_kwargs = mock_connect .call_args [1 ]
305304 assert call_kwargs ["client_keys" ] == "/home/user/.ssh/id_rsa"
@@ -312,7 +311,7 @@ async def test_execute_with_inline_input(self, hass: HomeAssistant) -> None:
312311 data = {** SERVICE_DATA_BASE , "input" : "inline input" }
313312 with patch ("custom_components.ssh_command.coordinator.connect" ,
314313 return_value = _MockConnect (mock_conn )):
315- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
314+ with patch ("pathlib.Path .exists" , return_value = False ):
316315 await hass .services .async_call (
317316 DOMAIN ,
318317 SERVICE_EXECUTE ,
@@ -337,7 +336,7 @@ async def test_execute_with_input_file(self, hass: HomeAssistant) -> None:
337336 data = {** SERVICE_DATA_BASE , "command" : "cat" , "input" : tf_path }
338337 with patch ("custom_components.ssh_command.coordinator.connect" ,
339338 return_value = _MockConnect (mock_conn )):
340- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = True ):
339+ with patch ("pathlib.Path .exists" , return_value = True ):
341340 await hass .services .async_call (
342341 DOMAIN ,
343342 SERVICE_EXECUTE ,
@@ -359,7 +358,7 @@ async def test_execute_with_custom_timeout(self, hass: HomeAssistant) -> None:
359358 data = {** SERVICE_DATA_BASE , "timeout" : 60 }
360359 with patch ("custom_components.ssh_command.coordinator.connect" ,
361360 return_value = _MockConnect (mock_conn )):
362- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
361+ with patch ("pathlib.Path .exists" , return_value = False ):
363362 await hass .services .async_call (
364363 DOMAIN ,
365364 SERVICE_EXECUTE ,
@@ -387,7 +386,7 @@ async def test_check_known_hosts_false_passes_none(self, hass: HomeAssistant) ->
387386 mock_conn = _make_mock_conn ()
388387 with patch ("custom_components.ssh_command.coordinator.connect" ,
389388 return_value = _MockConnect (mock_conn )) as mock_connect :
390- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
389+ with patch ("pathlib.Path .exists" , return_value = False ):
391390 await hass .services .async_call (
392391 DOMAIN ,
393392 SERVICE_EXECUTE ,
@@ -412,7 +411,7 @@ async def test_check_known_hosts_true_with_custom_file(self, hass: HomeAssistant
412411 }
413412 with patch ("custom_components.ssh_command.coordinator.connect" ,
414413 return_value = _MockConnect (mock_conn )) as mock_connect :
415- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = True ):
414+ with patch ("pathlib.Path .exists" , return_value = True ):
416415 with patch ("custom_components.ssh_command.coordinator.read_known_hosts" ,
417416 return_value = mock_known_hosts ) as mock_rkh :
418417 await hass .services .async_call (
@@ -440,7 +439,7 @@ async def test_check_known_hosts_true_with_missing_file(self, hass: HomeAssistan
440439 }
441440 with patch ("custom_components.ssh_command.coordinator.connect" ,
442441 return_value = _MockConnect (mock_conn )) as mock_connect :
443- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
442+ with patch ("pathlib.Path .exists" , return_value = False ):
444443 await hass .services .async_call (
445444 DOMAIN ,
446445 SERVICE_EXECUTE ,
@@ -463,7 +462,7 @@ async def test_check_known_hosts_true_uses_default_path_when_missing(
463462 data = {** SERVICE_DATA_BASE , "check_known_hosts" : True }
464463 with patch ("custom_components.ssh_command.coordinator.connect" ,
465464 return_value = _MockConnect (mock_conn )) as mock_connect :
466- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
465+ with patch ("pathlib.Path .exists" , return_value = False ):
467466 await hass .services .async_call (
468467 DOMAIN ,
469468 SERVICE_EXECUTE ,
@@ -521,7 +520,7 @@ async def test_key_file_not_found_raises(self, hass: HomeAssistant) -> None:
521520 entry = _make_entry ()
522521 await _setup_entry (hass , entry )
523522
524- with patch ("custom_components.ssh_command .exists" , return_value = False ):
523+ with patch ("pathlib.Path .exists" , return_value = False ):
525524 with pytest .raises (ServiceValidationError ) as exc_info :
526525 await hass .services .async_call (
527526 DOMAIN ,
@@ -592,7 +591,7 @@ async def test_host_key_not_verifiable(self, hass: HomeAssistant) -> None:
592591
593592 with patch ("custom_components.ssh_command.coordinator.connect" ,
594593 return_value = _MockConnectRaises (HostKeyNotVerifiable ("test" ))):
595- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
594+ with patch ("pathlib.Path .exists" , return_value = False ):
596595 with pytest .raises (ServiceValidationError ) as exc_info :
597596 await hass .services .async_call (
598597 DOMAIN ,
@@ -610,7 +609,7 @@ async def test_permission_denied(self, hass: HomeAssistant) -> None:
610609
611610 with patch ("custom_components.ssh_command.coordinator.connect" ,
612611 return_value = _MockConnectRaises (PermissionDenied ("auth failed" ))):
613- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
612+ with patch ("pathlib.Path .exists" , return_value = False ):
614613 with pytest .raises (ServiceValidationError ) as exc_info :
615614 await hass .services .async_call (
616615 DOMAIN ,
@@ -628,7 +627,7 @@ async def test_timeout(self, hass: HomeAssistant) -> None:
628627
629628 with patch ("custom_components.ssh_command.coordinator.connect" ,
630629 return_value = _MockConnectRaises (TimeoutError ())):
631- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
630+ with patch ("pathlib.Path .exists" , return_value = False ):
632631 with pytest .raises (ServiceValidationError ) as exc_info :
633632 await hass .services .async_call (
634633 DOMAIN ,
@@ -647,7 +646,7 @@ async def test_host_not_reachable(self, hass: HomeAssistant) -> None:
647646
648647 with patch ("custom_components.ssh_command.coordinator.connect" ,
649648 return_value = _MockConnectRaises (err )):
650- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
649+ with patch ("pathlib.Path .exists" , return_value = False ):
651650 with pytest .raises (ServiceValidationError ) as exc_info :
652651 await hass .services .async_call (
653652 DOMAIN ,
@@ -666,7 +665,7 @@ async def test_other_oserror_is_reraised(self, hass: HomeAssistant) -> None:
666665
667666 with patch ("custom_components.ssh_command.coordinator.connect" ,
668667 return_value = _MockConnectRaises (err )):
669- with patch ("custom_components.ssh_command.coordinator .exists" , return_value = False ):
668+ with patch ("pathlib.Path .exists" , return_value = False ):
670669 with pytest .raises (OSError ):
671670 await hass .services .async_call (
672671 DOMAIN ,
0 commit comments