From bff7dbe045239ad6cfca2e0fcf8f50f103a9c653 Mon Sep 17 00:00:00 2001 From: Manuel Giffels Date: Wed, 25 May 2022 13:43:36 +0200 Subject: [PATCH] Fix sqlite3 remote_resource_uuid update --- docs/source/changelog.rst | 4 ++-- tardis/plugins/sqliteregistry.py | 1 + tests/plugins_t/test_sqliteregistry.py | 9 ++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 695e517f..efe5b84b 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,4 +1,4 @@ -.. Created by changelog.py at 2022-05-11, command +.. Created by changelog.py at 2022-05-25, command '/Users/giffler/.cache/pre-commit/repor6pnmwlm/py_env-default/bin/changelog docs/source/changes compile --output=docs/source/changelog.rst' based on the format of 'https://keepachangelog.com/' @@ -6,7 +6,7 @@ CHANGELOG ######### -[Unreleased] - 2022-05-11 +[Unreleased] - 2022-05-25 ========================= Added diff --git a/tardis/plugins/sqliteregistry.py b/tardis/plugins/sqliteregistry.py index 7e8d2a37..e3030f43 100644 --- a/tardis/plugins/sqliteregistry.py +++ b/tardis/plugins/sqliteregistry.py @@ -190,6 +190,7 @@ async def notify(self, state: State, resource_attributes: AttributeDict) -> None async def update_resource(self, bind_parameters: Dict) -> None: sql_query = """UPDATE Resources SET updated = :updated, + remote_resource_uuid = :remote_resource_uuid, state_id = (SELECT state_id FROM ResourceStates WHERE state = :state) WHERE drone_uuid = :drone_uuid AND site_id = (SELECT site_id FROM Sites WHERE site_name = :site_name)""" diff --git a/tests/plugins_t/test_sqliteregistry.py b/tests/plugins_t/test_sqliteregistry.py index 9649e701..2a32d01d 100644 --- a/tests/plugins_t/test_sqliteregistry.py +++ b/tests/plugins_t/test_sqliteregistry.py @@ -1,7 +1,6 @@ import logging from tardis.resources.dronestates import BootingState -from tardis.resources.dronestates import IntegrateState from tardis.resources.dronestates import RequestState, DownState from tardis.interfaces.state import State from tardis.plugins.sqliteregistry import SqliteRegistry @@ -27,7 +26,7 @@ def setUpClass(cls): cls.test_machine_type = "MyGreatTestMachineType" cls.tables_in_db = {"MachineTypes", "Resources", "ResourceStates", "Sites"} cls.test_resource_attributes = { - "remote_resource_uuid": "bf85022b-fdd6-42b1-932d-086c288d4755", + "remote_resource_uuid": None, "drone_uuid": f"{cls.test_site_name}-07af52405e", "site_name": cls.test_site_name, "machine_type": cls.test_machine_type, @@ -66,7 +65,7 @@ def setUpClass(cls): cls.test_updated_notify_result = ( cls.test_updated_resource_attributes["remote_resource_uuid"], cls.test_updated_resource_attributes["drone_uuid"], - str(IntegrateState()), + str(BootingState()), cls.test_updated_resource_attributes["site_name"], cls.test_updated_resource_attributes["machine_type"], str(cls.test_updated_resource_attributes["created"]), @@ -220,7 +219,7 @@ def fetch_all(): run_async( self.registry.notify, - IntegrateState(), + BootingState(), self.test_updated_resource_attributes, ) @@ -250,7 +249,7 @@ def fetch_all(): self.registry.add_site(site_name) self.registry.add_machine_types(site_name, self.test_machine_type) - bind_parameters = {"state": "RequestState"} + bind_parameters = {"state": str(RequestState())} bind_parameters.update(self.test_resource_attributes) run_async(self.registry.insert_resource, bind_parameters)