diff --git a/server/api/tests/projects/experiments_and_analysis/conftest.py b/server/api/tests/projects/experiments_and_analysis/conftest.py index 207dd381246d621ea266acec1c802db8195712b5..81fee03cccb2682df66d7cddf84e486694178f59 100644 --- a/server/api/tests/projects/experiments_and_analysis/conftest.py +++ b/server/api/tests/projects/experiments_and_analysis/conftest.py @@ -131,11 +131,11 @@ def mock_analysis_wf(mocker): def mock_run_analysis(*args, **kwargs): return {"history_id": "history_id", "workflow_id": "workflow_id", "id": "id"} - def mock_load_results(*args, **kwargs): - print("fake load analyis results") + # def mock_load_results(*args, **kwargs): + # print("fake load analyis results") mocker.patch("api.serializers.run_analyis", mock_run_analysis) - mocker.patch("api.serializers.load_results", mock_load_results) + # mocker.patch("api.serializers.load_results", mock_load_results) yield mocker @@ -217,6 +217,13 @@ def analysis_tool_params(): @pytest.fixture +def workflow_id(): + yield "657f009ad32a3f27" + + +@pytest.fixture( + params=["657f009ad32a3f27"], ids=["v0.22_11"], +) def analysis_created_from_api_response( api_client, user_created_with_api, @@ -226,7 +233,8 @@ def analysis_created_from_api_response( user_password, analysis_tool_params, mock_analysis_wf, - mock_get_history_status_in_model + mock_get_history_status_in_model, + request, ): client = authenticate(api_client, user_created_with_api, user_password) @@ -238,6 +246,7 @@ def analysis_created_from_api_response( "galaxy_history_id": "", "experiments": [experiment_created_from_api.id], "toolsParams": analysis_tool_params, + "galaxy_workflow_id": request.param, }, format="json", ) @@ -261,15 +270,17 @@ def lodscores_created_from_task_result( mock_show_history_factory({"name": "xxxx_lod.csv", "id": "lodscores.csv"}) mock_download_dataset_factory() yield load_lod_score( - analysis_created_from_api.name, analysis_created_from_api.galaxy_history_id + ( + analysis_created_from_api.id, + analysis_created_from_api.galaxy_history_id, + "", + ) ) @pytest.fixture def lodscores_created_from_task(lodscores_created_from_task_result): - lodscore = LodScore.objects.get( - id=lodscores_created_from_task_result["lodscores_id"] - ) + lodscore = LodScore.objects.get(id=lodscores_created_from_task_result[2]) yield lodscore @@ -285,13 +296,13 @@ def peaks_created_from_task_result( mock_show_history_factory({"name": "xxxx_refine-peaks.csv", "id": "peaks.csv"}) mock_download_dataset_factory() yield load_refine_peaks( - analysis_created_from_api.name, analysis_created_from_api.galaxy_history_id + (analysis_created_from_api.id, analysis_created_from_api.galaxy_history_id, "",) ) @pytest.fixture def peaks_created_from_task(peaks_created_from_task_result): - peaks = Peak.objects.filter(id__in=peaks_created_from_task_result["peak_ids"]) + peaks = Peak.objects.filter(id__in=peaks_created_from_task_result[2]) yield peaks @@ -313,15 +324,13 @@ def coefficients_created_from_task_result( ) mock_download_dataset_factory() yield load_coefficient( - analysis_created_from_api.name, analysis_created_from_api.galaxy_history_id + (analysis_created_from_api.id, analysis_created_from_api.galaxy_history_id, "") ) @pytest.fixture def coefficient_created_from_task(coefficients_created_from_task_result): - coeff = Coefficient.objects.get( - id=coefficients_created_from_task_result["coefficient_id"] - ) + coeff = Coefficient.objects.get(id=coefficients_created_from_task_result[2]) yield coeff @@ -343,13 +352,14 @@ def haplotypes_created_from_task_result( ) mock_download_dataset_factory() yield load_haplotypes( - analysis_created_from_api.name, analysis_created_from_api.galaxy_history_id + (analysis_created_from_api.id, analysis_created_from_api.galaxy_history_id, "") ) @pytest.fixture def haplotypes_created_from_task(haplotypes_created_from_task_result): - haplo = Haplotypes.objects.get(id=haplotypes_created_from_task_result["id"]) + print(haplotypes_created_from_task_result[2]) + haplo = Haplotypes.objects.get(id=haplotypes_created_from_task_result[2]) yield haplo @@ -371,13 +381,13 @@ def snps_assoc_created_from_task_result( ) mock_download_dataset_factory() yield load_snps_association( - analysis_created_from_api.name, analysis_created_from_api.galaxy_history_id + (analysis_created_from_api.id, analysis_created_from_api.galaxy_history_id, "",) ) @pytest.fixture def snps_assoc_created_from_task(snps_assoc_created_from_task_result): - snps = SnpsAssociation.objects.get(id=snps_assoc_created_from_task_result["id"]) + snps = SnpsAssociation.objects.get(id=snps_assoc_created_from_task_result[2]) yield snps @@ -400,13 +410,13 @@ def top_snps_created_from_task_result( ) mock_download_dataset_factory() yield load_top_snps( - analysis_created_from_api.name, analysis_created_from_api.galaxy_history_id + (analysis_created_from_api.id, analysis_created_from_api.galaxy_history_id, "",) ) @pytest.fixture def top_snps_created_from_task(top_snps_created_from_task_result): - snps = TopSnps.objects.get(id=top_snps_created_from_task_result["id"]) + snps = TopSnps.objects.get(id=top_snps_created_from_task_result[2]) yield snps @@ -426,7 +436,7 @@ def significance_threshold_created_from_task_result( ) mock_download_dataset_factory() yield load_significance_threshold( - analysis_created_from_api.name, analysis_created_from_api.galaxy_history_id + (analysis_created_from_api.id, analysis_created_from_api.galaxy_history_id, "",) ) @@ -435,7 +445,7 @@ def significance_threshold_created_from_task( significance_threshold_created_from_task_result, ): thresholds = LodScoreSignificanceThreshold.objects.filter( - id__in=significance_threshold_created_from_task_result["ids"] + id__in=significance_threshold_created_from_task_result[2] ) yield thresholds diff --git a/server/api/tests/projects/experiments_and_analysis/test_analysis.py b/server/api/tests/projects/experiments_and_analysis/test_analysis.py index 985f6c3990a6918b3df18a6feb6a2966f05feeea..691778ddbd873531209ec024279da6597806edfb 100644 --- a/server/api/tests/projects/experiments_and_analysis/test_analysis.py +++ b/server/api/tests/projects/experiments_and_analysis/test_analysis.py @@ -26,6 +26,7 @@ def test_analysis_permissions( analysis_tool_params, mock_delete_history, mock_get_history_status_in_model, + workflow_id, ): role_param = project_with_members_response[1] @@ -54,6 +55,7 @@ def test_analysis_permissions( "galaxy_history_id": "", "experiments": [experiment_created_from_api.id], "toolsParams": analysis_tool_params, + "galaxy_workflow_id": workflow_id, }, format="json", ) diff --git a/server/api/tests/projects/experiments_and_analysis/test_coefficients.py b/server/api/tests/projects/experiments_and_analysis/test_coefficients.py index 421612686cee5c2af29814bc6cba3525b7010509..906a4061b819c20a80af59afc75d6cb962903068 100644 --- a/server/api/tests/projects/experiments_and_analysis/test_coefficients.py +++ b/server/api/tests/projects/experiments_and_analysis/test_coefficients.py @@ -3,8 +3,10 @@ from api.tests.utils import authenticate @pytest.mark.django_db -def test_coefficient_creation(coefficients_created_from_task_result): - assert coefficients_created_from_task_result["status"] == "ok" +def test_coefficient_creation( + analysis_created_from_api, coefficients_created_from_task_result +): + assert coefficients_created_from_task_result[0] == analysis_created_from_api.id @pytest.mark.django_db diff --git a/server/api/tests/projects/experiments_and_analysis/test_haplotype.py b/server/api/tests/projects/experiments_and_analysis/test_haplotype.py index 904cbcfcb7aa806fe12f5dc376763a877700c16e..2b806f413a9592f874e29230791cc831221c0d88 100644 --- a/server/api/tests/projects/experiments_and_analysis/test_haplotype.py +++ b/server/api/tests/projects/experiments_and_analysis/test_haplotype.py @@ -3,8 +3,10 @@ from api.tests.utils import authenticate @pytest.mark.django_db -def test_haplotype_creation(haplotypes_created_from_task_result): - assert haplotypes_created_from_task_result["status"] == "ok" +def test_haplotype_creation( + analysis_created_from_api, haplotypes_created_from_task_result +): + assert haplotypes_created_from_task_result[0] == analysis_created_from_api.id @pytest.mark.django_db diff --git a/server/api/tests/projects/experiments_and_analysis/test_significance_thresholds.py b/server/api/tests/projects/experiments_and_analysis/test_significance_thresholds.py index 4642eebe07dfc77d2a00ac17b89da88013b560e4..e69e13d19f6879e7997db9e3c638804395de8154 100644 --- a/server/api/tests/projects/experiments_and_analysis/test_significance_thresholds.py +++ b/server/api/tests/projects/experiments_and_analysis/test_significance_thresholds.py @@ -4,9 +4,12 @@ from api.tests.utils import authenticate @pytest.mark.django_db def test_significance_thresholds_creation( - significance_threshold_created_from_task_result, + analysis_created_from_api, significance_threshold_created_from_task_result, ): - assert significance_threshold_created_from_task_result["status"] == "ok" + assert ( + significance_threshold_created_from_task_result[0] + == analysis_created_from_api.id + ) @pytest.mark.django_db @@ -16,7 +19,6 @@ def test_significance_thresholds_permissions( project_created_from_api, project_with_members_response, analysis_created_from_api, - user_password, significance_threshold_created_from_task, ): diff --git a/server/api/tests/projects/experiments_and_analysis/test_snps_associations.py b/server/api/tests/projects/experiments_and_analysis/test_snps_associations.py index d07eaf786a9c0104aeb8c7213ca247886081f18f..a19bf272f6cc188b0de94677c2ef40d3e8045566 100644 --- a/server/api/tests/projects/experiments_and_analysis/test_snps_associations.py +++ b/server/api/tests/projects/experiments_and_analysis/test_snps_associations.py @@ -3,8 +3,10 @@ from api.tests.utils import authenticate @pytest.mark.django_db -def test_snps_assoc_creation(snps_assoc_created_from_task_result): - assert snps_assoc_created_from_task_result["status"] == "ok" +def test_snps_assoc_creation( + analysis_created_from_api, snps_assoc_created_from_task_result +): + assert snps_assoc_created_from_task_result[2] == analysis_created_from_api.id @pytest.mark.django_db diff --git a/server/api/tests/projects/experiments_and_analysis/test_top_snps.py b/server/api/tests/projects/experiments_and_analysis/test_top_snps.py index 13aadde9ffa622722ebc8545f89d3a0d14f91f8d..edec14110c5c8a3b41a09e94bdc17b885ca60a80 100644 --- a/server/api/tests/projects/experiments_and_analysis/test_top_snps.py +++ b/server/api/tests/projects/experiments_and_analysis/test_top_snps.py @@ -3,8 +3,10 @@ from api.tests.utils import authenticate @pytest.mark.django_db -def test_top_snps_creation(top_snps_created_from_task_result): - assert top_snps_created_from_task_result["status"] == "ok" +def test_top_snps_creation( + analysis_created_from_api, top_snps_created_from_task_result +): + assert top_snps_created_from_task_result[2] == analysis_created_from_api.id @pytest.mark.django_db diff --git a/server/api/tests/test_tasks.py b/server/api/tests/test_tasks.py index ee5f8007f67474027002748b849e0eb3ace2b196..4697b33b09ab155928085c84900181bdf1097022 100644 --- a/server/api/tests/test_tasks.py +++ b/server/api/tests/test_tasks.py @@ -37,14 +37,26 @@ def mock_show_dataset(mocker): yield mocker +@pytest.fixture +def mock_rmtree(mocker): + def _mock_rmtree(*args, **kwargs): + print("mocking rmtree") + + mocker.patch("api.tasks.shutil.rmtree", _mock_rmtree) + yield mocker + + def test_celery_raw_fixtures( mock_show_job, mock_upload_file, mock_show_dataset, + mock_rmtree, upload_data_id # celery_app, # celery_session_worker, ): - res = upload_file_to_galaxy("/toto", "history_id", "auto") - assert res == upload_data_id + analysis_id = 1 + history_id = "history_id" + res = upload_file_to_galaxy((analysis_id, history_id), "/fake-folder", "auto") + assert res[2] == upload_data_id