@@ -24,18 +24,10 @@ async def setup_script(hass, notify_q, now, source):
24
24
scripts = [
25
25
"/some/config/dir/pyscript/hello.py" ,
26
26
]
27
- integration = loader .Integration (
28
- hass ,
29
- "custom_components.pyscript" ,
30
- pathlib .Path ("custom_components/pyscript" ),
31
- {"name" : "pyscript" , "dependencies" : [], "requirements" : [], "domain" : "automation" },
32
- )
33
27
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 (
39
31
"custom_components.pyscript.trigger.dt_now" , return_value = now
40
32
), patch (
41
33
"homeassistant.config.load_yaml_config_file" , return_value = {}
@@ -67,16 +59,9 @@ async def wait_until_done(notify_q):
67
59
68
60
async def test_setup_makedirs_on_no_dir (hass , caplog ):
69
61
"""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 :
80
65
res = await async_setup_component (hass , "pyscript" , {DOMAIN : {}})
81
66
82
67
assert res
@@ -237,7 +222,7 @@ def func_yaml_doc_string(param2=None, param3=None):
237
222
{"name" : "pyscript" , "dependencies" : [], "requirements" : [], "domain" : "automation" },
238
223
)
239
224
240
- with patch ("homeassistant.loader.async_get_integration" , return_value = integration ), patch (
225
+ with patch (
241
226
"homeassistant.loader.async_get_custom_components" , return_value = {"pyscript" : integration },
242
227
):
243
228
descriptions = await async_get_all_descriptions (hass )
@@ -442,16 +427,10 @@ def func5(var_name=None, value=None):
442
427
scripts = [
443
428
"/some/config/dir/pyscript/hello.py" ,
444
429
]
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 (
455
434
"custom_components.pyscript.global_ctx.open" , mock_open (read_data = next_source ), create = True ,
456
435
), patch (
457
436
"custom_components.pyscript.trigger.dt_now" , return_value = now
0 commit comments