tags
This commit is contained in:
1 parent
02cbacabe0
commit
f8b59c6b17
7 files changed
+71
-56
No files matched your search
@@ -64,53 +64,3 @@ class db_tests(TestWithDB):
|
||||
autos = list(self.db.list_automations(0, 10))
|
||||
self.assertEqual(len(autos), 1)
|
||||
self.assertTrue(autos[0] == originals[1])
|
||||
|
||||
def test_delete_automations(self):
|
||||
originals = [
|
||||
ExtenededAutomation(
|
||||
id="test",
|
||||
alias="test",
|
||||
source_file="automation.yaml",
|
||||
source_file_type="obj",
|
||||
configuration_key="automation",
|
||||
),
|
||||
ExtenededAutomation(
|
||||
id="test2",
|
||||
alias="test",
|
||||
source_file="automation.yaml",
|
||||
source_file_type="obj",
|
||||
action=[{"event": {"nice": "one"}, "event_type": "custom"}],
|
||||
configuration_key="automation",
|
||||
),
|
||||
]
|
||||
self.assertEqual(self.db.count_automations(), 0)
|
||||
self.db.upsert_automations(originals)
|
||||
self.assertEqual(self.db.count_automations(), 2)
|
||||
self.db.delete_automations(originals)
|
||||
self.assertEqual(self.db.count_automations(), 0)
|
||||
|
||||
def test_delete_automations_by_source_type(self):
|
||||
originals = [
|
||||
ExtenededAutomation(
|
||||
id="test",
|
||||
alias="test",
|
||||
source_file="automation2.yaml",
|
||||
source_file_type="obj",
|
||||
configuration_key="automation",
|
||||
),
|
||||
ExtenededAutomation(
|
||||
id="test2",
|
||||
alias="test",
|
||||
source_file="automation.yaml",
|
||||
source_file_type="obj",
|
||||
action=[{"event": {"nice": "one"}, "event_type": "custom"}],
|
||||
configuration_key="automation",
|
||||
),
|
||||
]
|
||||
self.assertEqual(self.db.count_automations(), 0)
|
||||
self.db.upsert_automations(originals)
|
||||
self.assertEqual(self.db.count_automations(), 2)
|
||||
self.db.delete_automations_in_source_file(Path("automation2.yaml"))
|
||||
self.assertEqual(self.db.count_automations(), 1)
|
||||
[auto] = self.db.list_automations(0, 10)
|
||||
self.assertEqual(auto.id, "test2")
|
||||
Reference in new issue
Block a user