diff --git a/cg/cli/upload/scout.py b/cg/cli/upload/scout.py index 3e4693c803..4ddf4ff87f 100644 --- a/cg/cli/upload/scout.py +++ b/cg/cli/upload/scout.py @@ -50,6 +50,12 @@ def upload_to_scout(context, re_upload: bool, print_console: bool, case_id: str) suggest_cases_to_upload(status_db=status_db) return + case_obj: Case = status_db.get_case_by_internal_id(internal_id=case_id) + if case_obj.analyses == Workflow.TOMTE: + context.invoke( + upload_rna_to_scout, case_id=case_id, re_upload=re_upload, analysis=case_obj.analyses + ) + context.invoke( create_scout_load_config, case_id=case_id, print_console=print_console, re_upload=re_upload ) diff --git a/cg/meta/upload/scout/uploadscoutapi.py b/cg/meta/upload/scout/uploadscoutapi.py index e1fe01327c..e4f4a66fac 100644 --- a/cg/meta/upload/scout/uploadscoutapi.py +++ b/cg/meta/upload/scout/uploadscoutapi.py @@ -539,13 +539,6 @@ def get_config_builder(self, analysis, hk_version) -> ScoutConfigBuilder: Workflow.RNAFUSION: RnafusionConfigBuilder( hk_version_obj=hk_version, analysis_obj=analysis, lims_api=self.lims ), - Workflow.TOMTE: TomteConfigBuilder( - hk_version_obj=hk_version, - analysis_obj=analysis, - mip_analysis_api=self.mip_analysis_api, - lims_api=self.lims, - madeline_api=self.madeline_api, - ), } return config_builders[analysis.workflow] diff --git a/tests/cli/upload/test_cli_scout.py b/tests/cli/upload/test_cli_scout.py index 4c6bd78fcd..5b05fad390 100644 --- a/tests/cli/upload/test_cli_scout.py +++ b/tests/cli/upload/test_cli_scout.py @@ -1,21 +1,51 @@ import logging import mock +import pytest from click.testing import CliRunner, Result from cg.cli.upload.scout import create_scout_load_config, get_upload_api from cg.constants import EXIT_SUCCESS, Workflow from cg.meta.upload.scout.uploadscoutapi import UploadScoutAPI from cg.meta.upload.upload_api import UploadAPI +from cg.meta.workflow.analysis import AnalysisAPI from cg.meta.workflow.balsamic import BalsamicAnalysisAPI +from cg.meta.workflow.mip_dna import MipDNAAnalysisAPI +from cg.meta.workflow.mip_rna import MipRNAAnalysisAPI +from cg.meta.workflow.rnafusion import RnafusionAnalysisAPI +from cg.meta.workflow.tomte import TomteAnalysisAPI from cg.models.cg_config import CGConfig from cg.store.models import Case from cg.store.store import Store from tests.mocks.scout import MockScoutLoadConfig from tests.store_helpers import StoreHelpers +WORKFLOWS_TO_TEST: list = [ + Workflow.BALSAMIC, + Workflow.MIP_DNA, + Workflow.MIP_RNA, + Workflow.RNAFUSION, + Workflow.TOMTE, +] -def test_get_upload_api(cg_context: CGConfig, case_id: str, helpers: StoreHelpers): +ANALYSIS_API: dict[Workflow, UploadAPI] = [ + (Workflow.BALSAMIC, BalsamicAnalysisAPI)(Workflow.MIP_DNA, MipDNAAnalysisAPI)( + Workflow.MIP_RNA, MipRNAAnalysisAPI + )(Workflow.RNAFUSION, RnafusionAnalysisAPI)(Workflow.TOMTE, TomteAnalysisAPI) +] + + +@pytest.mark.parametrize( + "workflow,analysis_api", + ANALYSIS_API, +) +def test_get_upload_api( + cg_context: CGConfig, + case_id: str, + helpers: StoreHelpers, + workflow: Workflow, + analysis_api: AnalysisAPI, +): """Test to get the correct upload API for a BALSAMIC case.""" status_db: Store = cg_context.status_db @@ -23,31 +53,34 @@ def test_get_upload_api(cg_context: CGConfig, case_id: str, helpers: StoreHelper case: Case = helpers.ensure_case( store=status_db, data_analysis=Workflow.BALSAMIC, case_id=case_id ) - helpers.add_analysis(store=status_db, case=case, workflow=Workflow.BALSAMIC) + helpers.add_analysis(store=status_db, case=case, workflow=workflow) # WHEN getting the upload API upload_api: UploadAPI = get_upload_api(cg_config=cg_context, case=case) # THEN assert that the type of upload API is correct - assert type(upload_api.analysis_api) == BalsamicAnalysisAPI + assert type(upload_api.analysis_api) is analysis_api +@pytest.mark.parametrize( + "workflow", + WORKFLOWS_TO_TEST, +) def test_create_scout_load_config( caplog, cli_runner: CliRunner, cg_context: CGConfig, case_id: str, helpers: StoreHelpers, + workflow: Workflow, ): """Test to create a scout load config for a BALSAMIC case.""" caplog.set_level(logging.DEBUG) status_db: Store = cg_context.status_db # GIVEN a case with a balsamic analysis - case: Case = helpers.ensure_case( - store=status_db, data_analysis=Workflow.BALSAMIC, case_id=case_id - ) - helpers.add_analysis(store=status_db, case=case, workflow=Workflow.BALSAMIC) + case: Case = helpers.ensure_case(store=status_db, data_analysis=workflow, case_id=case_id) + helpers.add_analysis(store=status_db, case=case, workflow=workflow) with mock.patch.object(UploadScoutAPI, "generate_config", return_value=MockScoutLoadConfig()): # WHEN creating the scout load config