additional api refactor
This commit is contained in:
1 parent
8792ed6ed8
commit
7cb1a5d907
11 files changed
+415
-271
No files matched your search
@@ -22,14 +22,14 @@ class db_tests(TestWithDB):
|
||||
ExtenededAutomation(
|
||||
id="test",
|
||||
alias="test",
|
||||
source_file=Path("automation.yaml").absolute(),
|
||||
source_file="automation.yaml",
|
||||
source_file_type="obj",
|
||||
configuration_key="automation",
|
||||
),
|
||||
ExtenededAutomation(
|
||||
id="test2",
|
||||
alias="test",
|
||||
source_file=Path("automation.yaml").absolute(),
|
||||
source_file="automation.yaml",
|
||||
source_file_type="obj",
|
||||
action=[{"event": {"nice": "one"}, "event_type": "custom"}],
|
||||
configuration_key="automation",
|
||||
@@ -47,14 +47,14 @@ class db_tests(TestWithDB):
|
||||
ExtenededAutomation(
|
||||
id="test",
|
||||
alias="test",
|
||||
source_file=Path("automation.yaml").absolute(),
|
||||
source_file="automation.yaml",
|
||||
source_file_type="obj",
|
||||
configuration_key="automation",
|
||||
),
|
||||
ExtenededAutomation(
|
||||
id="test",
|
||||
alias="test",
|
||||
source_file=Path("automation.yaml").absolute(),
|
||||
source_file="automation.yaml",
|
||||
source_file_type="obj",
|
||||
action=[{"event": {"nice": "one"}, "event_type": "custom"}],
|
||||
configuration_key="automation",
|
||||
|
||||
@@ -23,6 +23,7 @@ class loader_tests(TestCase):
|
||||
def test_load_automation_list_file(self):
|
||||
automations = list(
|
||||
load_automation_path(
|
||||
HA_CONFIG2_EXAMPLE,
|
||||
HA_CONFIG2_EXAMPLE / "automations.yaml",
|
||||
configuration_key="automation",
|
||||
tag_manager=TagManager({"1652069225859": {"type": "routine"}}),
|
||||
@@ -33,7 +34,7 @@ class loader_tests(TestCase):
|
||||
automations[0],
|
||||
ExtenededAutomation(
|
||||
id="1652069225859",
|
||||
source_file=str(HA_CONFIG2_EXAMPLE / "automations.yaml"),
|
||||
source_file="automations.yaml",
|
||||
source_file_type="list",
|
||||
configuration_key="automation",
|
||||
alias="Climate - Pref temperature ",
|
||||
@@ -66,6 +67,7 @@ class loader_tests(TestCase):
|
||||
def test_load_automation_obj_file(self):
|
||||
automations = list(
|
||||
load_automation_path(
|
||||
HA_CONFIG4_EXAMPLE,
|
||||
HA_CONFIG4_EXAMPLE / "automations" / "notify_washer.yaml",
|
||||
configuration_key="automation base",
|
||||
tag_manager=TagManager({"1659114647067": {"room": "laundry"}}),
|
||||
@@ -76,7 +78,7 @@ class loader_tests(TestCase):
|
||||
automations[0],
|
||||
ExtenededAutomation(
|
||||
id="1659114647067",
|
||||
source_file=str(HA_CONFIG4_EXAMPLE / "automations" / "notify_washer.yaml"),
|
||||
source_file="automations/notify_washer.yaml",
|
||||
source_file_type="obj",
|
||||
configuration_key="automation base",
|
||||
alias="Notify Washer",
|
||||
@@ -105,6 +107,7 @@ class loader_tests(TestCase):
|
||||
file_path.touch()
|
||||
automations = list(
|
||||
load_automation_path(
|
||||
file_path.parent,
|
||||
file_path,
|
||||
configuration_key="automation ui",
|
||||
tag_manager=TagManager(),
|
||||
@@ -117,6 +120,7 @@ class loader_tests(TestCase):
|
||||
file_path.unlink(missing_ok=True)
|
||||
automations = list(
|
||||
load_automation_path(
|
||||
file_path.parent,
|
||||
file_path,
|
||||
configuration_key="automation manual",
|
||||
tag_manager=TagManager(),
|
||||
|
||||
@@ -49,7 +49,7 @@ class manager_tests(TestWithDB):
|
||||
automation.trigger.append(
|
||||
{"platform": "zone", "entity_id": "person.thor", "zone": "zone.azguard"}
|
||||
)
|
||||
automation_manager.upsert(automation)
|
||||
automation_manager.update(automation)
|
||||
self.assertEqual(
|
||||
automation_manager.get("sublist3-mlist2").trigger,
|
||||
[],
|
||||
@@ -124,11 +124,11 @@ class manager_tests(TestWithDB):
|
||||
self.assertFalse((config_path / "automations/include_dir_list/home/left.yaml").exists())
|
||||
with self.assertRaises(DBNoAutomationFound):
|
||||
automation_manager.get("newlymade")
|
||||
automation_manager.upsert(
|
||||
automation_manager.update(
|
||||
ExtenededAutomation(
|
||||
id="newlymade",
|
||||
configuration_key="automation manual",
|
||||
source_file=config_path / "automations/include_dir_list/home/left.yaml",
|
||||
source_file="automations/include_dir_list/home/left.yaml",
|
||||
source_file_type="obj",
|
||||
)
|
||||
)
|
||||
@@ -139,7 +139,7 @@ class manager_tests(TestWithDB):
|
||||
ExtenededAutomation(
|
||||
id="newlymade",
|
||||
configuration_key="automation manual",
|
||||
source_file=config_path / "automations/include_dir_list/home/left.yaml",
|
||||
source_file="automations/include_dir_list/home/left.yaml",
|
||||
source_file_type="obj",
|
||||
),
|
||||
)
|
||||
@@ -152,13 +152,14 @@ class manager_tests(TestWithDB):
|
||||
)
|
||||
with self.assertRaises(DBNoAutomationFound):
|
||||
automation_manager.get("newlymade")
|
||||
automation_manager.upsert(
|
||||
automation_manager.update(
|
||||
ExtenededAutomation(
|
||||
id="newlymade",
|
||||
configuration_key="automation cools",
|
||||
source_file=config_path / "automations/include_dir_merge_list/sub/list2.yaml",
|
||||
source_file="automations/include_dir_merge_list/sub/list2.yaml",
|
||||
source_file_type="list",
|
||||
)
|
||||
),
|
||||
create_if_not_found=True,
|
||||
)
|
||||
self.assertTrue(
|
||||
(config_path / "automations/include_dir_merge_list/sub/list2.yaml").exists()
|
||||
@@ -169,7 +170,7 @@ class manager_tests(TestWithDB):
|
||||
ExtenededAutomation(
|
||||
id="newlymade",
|
||||
configuration_key="automation cools",
|
||||
source_file=config_path / "automations/include_dir_merge_list/sub/list2.yaml",
|
||||
source_file="automations/include_dir_merge_list/sub/list2.yaml",
|
||||
source_file_type="list",
|
||||
),
|
||||
)
|
||||
@@ -182,13 +183,14 @@ class manager_tests(TestWithDB):
|
||||
)
|
||||
with self.assertRaises(DBNoAutomationFound):
|
||||
automation_manager.get("newlymade")
|
||||
automation_manager.upsert(
|
||||
automation_manager.update(
|
||||
ExtenededAutomation(
|
||||
id="newlymade",
|
||||
configuration_key="automation cools",
|
||||
source_file=config_path / "automations/include_dir_merge_list/sub/list4.yaml",
|
||||
source_file="automations/include_dir_merge_list/sub/list4.yaml",
|
||||
source_file_type="list",
|
||||
)
|
||||
),
|
||||
create_if_not_found=True,
|
||||
)
|
||||
self.assertTrue(
|
||||
(config_path / "automations/include_dir_merge_list/sub/list4.yaml").exists()
|
||||
@@ -199,7 +201,7 @@ class manager_tests(TestWithDB):
|
||||
ExtenededAutomation(
|
||||
id="newlymade",
|
||||
configuration_key="automation cools",
|
||||
source_file=config_path / "automations/include_dir_merge_list/sub/list4.yaml",
|
||||
source_file="automations/include_dir_merge_list/sub/list4.yaml",
|
||||
source_file_type="list",
|
||||
),
|
||||
)
|
||||
@@ -213,13 +215,14 @@ class manager_tests(TestWithDB):
|
||||
with self.assertRaises(DBNoAutomationFound):
|
||||
automation_manager.get("newlymade")
|
||||
with self.assertRaises(AttemptingToOverwriteAnIncompatibleFileError):
|
||||
automation_manager.upsert(
|
||||
automation_manager.update(
|
||||
ExtenededAutomation(
|
||||
id="newlymade",
|
||||
configuration_key="automation cools",
|
||||
source_file=config_path / "automations/include_dir_merge_list/sub/list2.yaml",
|
||||
source_file="automations/include_dir_merge_list/sub/list2.yaml",
|
||||
source_file_type="obj",
|
||||
)
|
||||
),
|
||||
create_if_not_found=True,
|
||||
)
|
||||
automation_manager.reload()
|
||||
with self.assertRaises(DBNoAutomationFound):
|
||||
@@ -237,13 +240,14 @@ class manager_tests(TestWithDB):
|
||||
with self.assertRaises(DBNoAutomationFound):
|
||||
automation_manager.get("newlymade")
|
||||
with self.assertRaises(AttemptingToOverwriteAnIncompatibleFileError):
|
||||
automation_manager.upsert(
|
||||
automation_manager.update(
|
||||
ExtenededAutomation(
|
||||
id="newlymade",
|
||||
configuration_key="automation cools",
|
||||
source_file=config_path / "automations/include_dir_list/home/down.yaml",
|
||||
source_file="automations/include_dir_list/home/down.yaml",
|
||||
source_file_type="list",
|
||||
)
|
||||
),
|
||||
create_if_not_found=True,
|
||||
)
|
||||
automation_manager.reload()
|
||||
with self.assertRaises(DBNoAutomationFound):
|
||||
@@ -266,7 +270,7 @@ class manager_tests(TestWithDB):
|
||||
},
|
||||
)
|
||||
auto.tags["Room"] = "Bathroom"
|
||||
automation_manager.upsert(auto)
|
||||
automation_manager.update(auto)
|
||||
del auto
|
||||
automation_manager.reload()
|
||||
auto = automation_manager.get("1619371298367")
|
||||
|
||||
Reference in new issue
Block a user