diff --git a/api/src/automations/db.py b/api/src/automations/db.py index 115536d..b1751f9 100644 --- a/api/src/automations/db.py +++ b/api/src/automations/db.py @@ -72,7 +72,7 @@ class AutomationDBConnection: """ ) - def upsert_automations(self, automations: List[ExtenededAutomation]): + def insert_automations(self, automations: List[ExtenededAutomation]): with self.get_cur() as cur: for automation in automations: cur.execute( @@ -86,16 +86,7 @@ class AutomationDBConnection: "{automation.source_file_type}", "{automation.configuration_key}", "{encode_auto(automation)}" - ) - ON CONFLICT DO UPDATE SET - alias = "{automation.alias}", - description = "{automation.description}", - mode = "{automation.mode}", - source_file = "{automation.source_file.absolute()}", - source_file_type = "{automation.source_file_type}", - configuration_key = "{automation.configuration_key}", - rest = "{encode_auto(automation)}" - + ); """, ) diff --git a/api/src/automations/manager.py b/api/src/automations/manager.py index 45efd95..ee0a262 100644 --- a/api/src/automations/manager.py +++ b/api/src/automations/manager.py @@ -46,7 +46,7 @@ class AutomationManager: for config_key, p in extract_automation_paths(self.hass_config): try: automations = list(load_automation_path(p, config_key, self.tag_manager)) - self.db.upsert_automations(automations) + self.db.insert_automations(automations) except InvalidAutomationFile as e: logger.warning(e) errors.append(e) diff --git a/api/tests/unittests/automations/test_db.py b/api/tests/unittests/automations/test_db.py index f35a0c4..2e89594 100644 --- a/api/tests/unittests/automations/test_db.py +++ b/api/tests/unittests/automations/test_db.py @@ -1,7 +1,7 @@ from pathlib import Path from src.automations.types import ExtenededAutomation - +from src.automations.errors import DBDataError from .utils import TestWithDB @@ -35,7 +35,7 @@ class db_tests(TestWithDB): configuration_key="automation", ), ] - self.db.upsert_automations(originals) + self.db.insert_automations(originals) for original in originals: with self.subTest(original=original): self.assertEqual(self.db.get_automation(original.id), original) @@ -60,7 +60,7 @@ class db_tests(TestWithDB): configuration_key="automation", ), ] - self.db.upsert_automations(originals) + with self.assertRaises(DBDataError): + self.db.insert_automations(originals) autos = list(self.db.list_automations(0, 10)) - self.assertEqual(len(autos), 1) - self.assertTrue(autos[0] == originals[1]) + self.assertEqual(len(autos), 0) diff --git a/api/web b/api/web deleted file mode 120000 index d074fc2..0000000 --- a/api/web +++ /dev/null @@ -1 +0,0 @@ -../webapp/build \ No newline at end of file