From c6c69c626a1c0140e0762c360451806c40d09067 Mon Sep 17 00:00:00 2001 From: martynia Date: Tue, 17 Dec 2024 17:39:45 +0100 Subject: [PATCH] fix: fix multiple inheritance. --- .../tests/pilot_logging/test_pilot_logger.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/diracx-routers/tests/pilot_logging/test_pilot_logger.py b/diracx-routers/tests/pilot_logging/test_pilot_logger.py index cf1e5bb4..f740e717 100644 --- a/diracx-routers/tests/pilot_logging/test_pilot_logger.py +++ b/diracx-routers/tests/pilot_logging/test_pilot_logger.py @@ -7,7 +7,6 @@ from diracx.core.properties import PILOT from diracx.db.os import PilotLogsDB -from diracx.db.os.utils import BaseOSDB from diracx.db.sql import PilotAgentsDB from diracx.db.sql.pilot_agents.schema import PilotAgents from diracx.routers.pilot_logging.remote_logger import ( @@ -16,11 +15,12 @@ get_logs, send_message, ) -from diracx.testing.mock_osdb import MockOSDBMixin, fake_available_osdb_implementations +from diracx.testing.mock_osdb import MockOSDBMixin - -class PilotLogsDB(MockOSDBMixin, PilotLogsDB): - pass +# class PilotLogsDB(MockOSDBMixin, PilotLogsDB): +# pass +# PilotLogsDB = fake_available_osdb_implementations("PilotLogsDB", +# real_available_implementations=BaseOSDB.available_implementations)[0] @pytest.fixture @@ -34,10 +34,10 @@ async def pilot_agents_db(tmp_path) -> PilotAgentsDB: @pytest.fixture async def pilot_logs_db(): - fake_implementation = fake_available_osdb_implementations( - "PilotLogsDB", real_available_implementations=BaseOSDB.available_implementations - )[0] - db = fake_implementation( + # create a class that has sqlite backend replacing OpenSearch PilotLogsDB + MPilotLogsDB = type("JobParametersDB", (MockOSDBMixin, PilotLogsDB), {}) + + db = MPilotLogsDB( connection_kwargs={"sqlalchemy_dsn": "sqlite+aiosqlite:///:memory:"} ) async with db.client_context(): @@ -48,7 +48,7 @@ async def pilot_logs_db(): @patch("diracx.routers.pilot_logging.remote_logger.BaseSQLDB.available_implementations") @patch("diracx.routers.pilot_logging.remote_logger.BaseSQLDB.available_urls") async def test_remote_logger( - mock_url, mock_impl, pilot_logs_db: PilotLogsDB, pilot_agents_db: PilotAgentsDB + mock_url, mock_impl, pilot_logs_db: "PilotLogsDB", pilot_agents_db: PilotAgentsDB ): async with pilot_agents_db as db: