inline automation support

This commit is contained in:
ari committed 2022-08-27 13:58:41 -04:00
1 parent fbbc5af12d
commit ac82a4c96c
7 files changed
+132 -48

No files matched your search

@@ -7,6 +7,7 @@ from fastapi.testclient import TestClient
from src.api.app import make_app
from src.automations.types import Automation, ExtenededAutomation
from tests.utils import (
HA_CONFIG10_EXAMPLE,
HA_CONFIG2_EXAMPLE,
HA_CONFIG6_EXAMPLE,
get_example_automation_loader,
@@ -386,6 +387,22 @@ class automation_update_split_config_tests(automation_update_tests):
self.client = TestClient(make_app(self.automation_loader))
class automation_update_split_config_and_inline_config_tests(automation_update_tests):
test_params = {
"total": 3,
"modify_item": 0,
"consitency_tests": {},
}
def setUp(self) -> None:
(
self.config_folder,
self.hass_config,
self.automation_loader,
) = get_example_automation_loader(HA_CONFIG10_EXAMPLE)
self.client = TestClient(make_app(self.automation_loader))
class automation_delete_tests(BaseTestCase):
def test_delete_some(self):
resp = self.client.post("/automations/list", json={"limit": 1, "offset": 0})
@@ -3,7 +3,7 @@ from tempfile import mktemp
from unittest import TestCase
from src.automations.loader import (
extract_automation_paths,
extract_automation_refs,
load_automation_path,
)
from src.automations.tags import TagManager
@@ -155,9 +155,9 @@ class loader_tests(TestCase):
(HA_CONFIG7_EXAMPLE, 1),
(HA_CONFIG8_EXAMPLE, 1),
(HA_CONFIG9_EXAMPLE, 1),
(HA_CONFIG10_EXAMPLE, 1),
(HA_CONFIG10_EXAMPLE, 2),
]:
with self.subTest(config_name=ha_path.name, expected=expected):
hass_config = HassConfig(ha_path)
paths = list(extract_automation_paths(hass_config))
self.assertEqual(len(paths), expected)
refs = list(extract_automation_refs(hass_config))
self.assertEqual(len(refs), expected)
@@ -334,5 +334,5 @@ class manager_tests(TestWithDB):
_, automation_manager = self.get_manager(HA_CONFIG10_EXAMPLE)
automation_manager.reload()
auto = automation_manager.get("inline-auto")
self.assertEqual(auto.source_file_type, ["inline"])
self.assertEqual(auto.source_file_type, "inline")
self.assertEqual(auto.configuration_key, ["automation"])