using sync process
This commit is contained in:
1 parent
7aadfbc175
commit
b0d924f63a
17 files changed
+384
-496
No files matched your search
@@ -3,7 +3,7 @@ from tempfile import mktemp
|
||||
from unittest import TestCase
|
||||
|
||||
from src.automations_v2.loader import extract_automation_paths, load_automation_path
|
||||
from src.automations_v2.types import ExtenededAutomationData
|
||||
from src.automations_v2.types import ExtenededAutomation
|
||||
from src.hass_config.loader import HassConfig
|
||||
from tests.utils import (
|
||||
HA_CONFIG2_EXAMPLE,
|
||||
@@ -17,14 +17,19 @@ from tests.utils import (
|
||||
|
||||
class loader_tests(TestCase):
|
||||
def test_load_automation_list_file(self):
|
||||
automations = list(load_automation_path(HA_CONFIG2_EXAMPLE / "automations.yaml"))
|
||||
automations = list(
|
||||
load_automation_path(
|
||||
HA_CONFIG2_EXAMPLE / "automations.yaml", configuration_key="automation"
|
||||
)
|
||||
)
|
||||
self.assertEqual(len(automations), 1)
|
||||
self.assertEqual(
|
||||
automations[0],
|
||||
ExtenededAutomationData(
|
||||
ExtenededAutomation(
|
||||
id="1652069225859",
|
||||
source_file=str(HA_CONFIG2_EXAMPLE / "automations.yaml"),
|
||||
source_file_type="list",
|
||||
configuration_key="automation",
|
||||
alias="Climate - Pref temperature ",
|
||||
description="",
|
||||
mode="single",
|
||||
@@ -53,15 +58,19 @@ class loader_tests(TestCase):
|
||||
|
||||
def test_load_automation_obj_file(self):
|
||||
automations = list(
|
||||
load_automation_path(HA_CONFIG4_EXAMPLE / "automations" / "notify_washer.yaml")
|
||||
load_automation_path(
|
||||
HA_CONFIG4_EXAMPLE / "automations" / "notify_washer.yaml",
|
||||
configuration_key="automation base",
|
||||
)
|
||||
)
|
||||
self.assertEqual(len(automations), 1)
|
||||
self.assertEqual(
|
||||
automations[0],
|
||||
ExtenededAutomationData(
|
||||
ExtenededAutomation(
|
||||
id="1659114647067",
|
||||
source_file=str(HA_CONFIG4_EXAMPLE / "automations" / "notify_washer.yaml"),
|
||||
source_file_type="obj",
|
||||
configuration_key="automation base",
|
||||
alias="Notify Washer",
|
||||
description="Example",
|
||||
mode="single",
|
||||
@@ -85,13 +94,13 @@ class loader_tests(TestCase):
|
||||
def test_load_automation_empty_file(self):
|
||||
file_path = Path(mktemp())
|
||||
file_path.touch()
|
||||
automations = list(load_automation_path(file_path))
|
||||
automations = list(load_automation_path(file_path, configuration_key="automation ui"))
|
||||
self.assertEqual(len(automations), 0)
|
||||
|
||||
def test_load_automation_none_existing_file(self):
|
||||
file_path = Path(mktemp())
|
||||
file_path.unlink(missing_ok=True)
|
||||
automations = list(load_automation_path(file_path))
|
||||
automations = list(load_automation_path(file_path, configuration_key="automation manual"))
|
||||
self.assertEqual(len(automations), 0)
|
||||
|
||||
def test_extract_all_automation_files(self):
|
||||
|
||||
Reference in new issue
Block a user