@@ -24,18 +24,10 @@ async def setup_script(hass, notify_q, now, source):
2424 scripts = [
2525 "/some/config/dir/pyscript/hello.py" ,
2626 ]
27- integration = loader .Integration (
28- hass ,
29- "custom_components.pyscript" ,
30- pathlib .Path ("custom_components/pyscript" ),
31- {"name" : "pyscript" , "dependencies" : [], "requirements" : [], "domain" : "automation" },
32- )
3327
34- with patch ("homeassistant.loader.async_get_integration" , return_value = integration ), patch (
35- "custom_components.pyscript.os.path.isdir" , return_value = True
36- ), patch ("custom_components.pyscript.glob.iglob" , return_value = scripts ), patch (
37- "custom_components.pyscript.global_ctx.open" , mock_open (read_data = source ), create = True ,
38- ), patch (
28+ with patch ("custom_components.pyscript.os.path.isdir" , return_value = True ), patch (
29+ "custom_components.pyscript.glob.iglob" , return_value = scripts
30+ ), patch ("custom_components.pyscript.global_ctx.open" , mock_open (read_data = source ), create = True ,), patch (
3931 "custom_components.pyscript.trigger.dt_now" , return_value = now
4032 ), patch (
4133 "homeassistant.config.load_yaml_config_file" , return_value = {}
@@ -67,16 +59,9 @@ async def wait_until_done(notify_q):
6759
6860async def test_setup_makedirs_on_no_dir (hass , caplog ):
6961 """Test setup calls os.makedirs when no dir found."""
70- integration = loader .Integration (
71- hass ,
72- "custom_components.pyscript" ,
73- pathlib .Path ("custom_components/pyscript" ),
74- {"name" : "pyscript" , "dependencies" : [], "requirements" : [], "domain" : "automation" },
75- )
76-
77- with patch ("homeassistant.loader.async_get_integration" , return_value = integration ), patch (
78- "custom_components.pyscript.os.path.isdir" , return_value = False
79- ), patch ("custom_components.pyscript.os.makedirs" ) as makedirs_call :
62+ with patch ("custom_components.pyscript.os.path.isdir" , return_value = False ), patch (
63+ "custom_components.pyscript.os.makedirs"
64+ ) as makedirs_call :
8065 res = await async_setup_component (hass , "pyscript" , {DOMAIN : {}})
8166
8267 assert res
@@ -237,7 +222,7 @@ def func_yaml_doc_string(param2=None, param3=None):
237222 {"name" : "pyscript" , "dependencies" : [], "requirements" : [], "domain" : "automation" },
238223 )
239224
240- with patch ("homeassistant.loader.async_get_integration" , return_value = integration ), patch (
225+ with patch (
241226 "homeassistant.loader.async_get_custom_components" , return_value = {"pyscript" : integration },
242227 ):
243228 descriptions = await async_get_all_descriptions (hass )
@@ -442,16 +427,10 @@ def func5(var_name=None, value=None):
442427 scripts = [
443428 "/some/config/dir/pyscript/hello.py" ,
444429 ]
445- integration = loader .Integration (
446- hass ,
447- "custom_components.pyscript" ,
448- pathlib .Path ("custom_components/pyscript" ),
449- {"name" : "pyscript" , "dependencies" : [], "requirements" : [], "domain" : "automation" },
450- )
451-
452- with patch ("homeassistant.loader.async_get_integration" , return_value = integration ), patch (
453- "custom_components.pyscript.os.path.isdir" , return_value = True
454- ), patch ("custom_components.pyscript.glob.iglob" , return_value = scripts ), patch (
430+
431+ with patch ("custom_components.pyscript.os.path.isdir" , return_value = True ), patch (
432+ "custom_components.pyscript.glob.iglob" , return_value = scripts
433+ ), patch (
455434 "custom_components.pyscript.global_ctx.open" , mock_open (read_data = next_source ), create = True ,
456435 ), patch (
457436 "custom_components.pyscript.trigger.dt_now" , return_value = now
0 commit comments