rapid changes

This commit is contained in:
ari committed 2022-08-14 01:26:11 -04:00
1 parent e11f4deab5
commit 586f52ba56
4 files changed
+90 -21

No files matched your search

@@ -1,5 +1,5 @@
from src.automations_v2.automation_watcher import AutomationFileWatcher
from tests.utils import HA_CONFIG6_EXAMPLE, create_copy_of_example_config
from tests.utils import HA_CONFIG6_EXAMPLE, HA_CONFIG_EXAMPLE, create_copy_of_example_config
from .utils import TestWithDB
@@ -40,6 +40,28 @@ class watcher_tests(TestWithDB):
self.assertEqual(self.db.count_automations(), 12)
watcher.join()
def test_rapid_changes(self):
example_folder = create_copy_of_example_config()
watcher = AutomationFileWatcher(example_folder / "automations.yaml", self.db_file)
watcher.start()
watcher.wait_until_next_reload(True)
self.assertEqual(self.db.count_automations(), 32)
(example_folder / "automations.yaml").write_text("")
(example_folder / "automations.yaml").write_text(
(HA_CONFIG_EXAMPLE / "automations.yaml").read_text()
)
(example_folder / "automations.yaml").write_text("")
(example_folder / "automations.yaml").write_text(
(HA_CONFIG_EXAMPLE / "automations.yaml").read_text()
)
(example_folder / "automations.yaml").write_text("")
(example_folder / "automations.yaml").write_text(
(HA_CONFIG_EXAMPLE / "automations.yaml").read_text()
)
watcher.wait_until_next_reload(True)
self.assertEqual(self.db.count_automations(), 32)
watcher.join()
# def test_valid_changes(self):
# example_folder = create_copy_of_example_config()
# watcher = AutomationFileWatcher(example_folder / "automations.yaml", self.db_file)