Skip to content
Snippets Groups Projects
Commit 7c75e430 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Fix tests

parent e0ee6940
Branches
Tags
1 merge request!74Resolve "select workflow to run"
Pipeline #66611 passed
...@@ -131,11 +131,11 @@ def mock_analysis_wf(mocker): ...@@ -131,11 +131,11 @@ def mock_analysis_wf(mocker):
def mock_run_analysis(*args, **kwargs): def mock_run_analysis(*args, **kwargs):
return {"history_id": "history_id", "workflow_id": "workflow_id", "id": "id"} return {"history_id": "history_id", "workflow_id": "workflow_id", "id": "id"}
def mock_load_results(*args, **kwargs): # def mock_load_results(*args, **kwargs):
print("fake load analyis results") # print("fake load analyis results")
mocker.patch("api.serializers.run_analyis", mock_run_analysis) 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 yield mocker
...@@ -217,6 +217,13 @@ def analysis_tool_params(): ...@@ -217,6 +217,13 @@ def analysis_tool_params():
@pytest.fixture @pytest.fixture
def workflow_id():
yield "657f009ad32a3f27"
@pytest.fixture(
params=["657f009ad32a3f27"], ids=["v0.22_11"],
)
def analysis_created_from_api_response( def analysis_created_from_api_response(
api_client, api_client,
user_created_with_api, user_created_with_api,
...@@ -226,7 +233,8 @@ def analysis_created_from_api_response( ...@@ -226,7 +233,8 @@ def analysis_created_from_api_response(
user_password, user_password,
analysis_tool_params, analysis_tool_params,
mock_analysis_wf, 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) client = authenticate(api_client, user_created_with_api, user_password)
...@@ -238,6 +246,7 @@ def analysis_created_from_api_response( ...@@ -238,6 +246,7 @@ def analysis_created_from_api_response(
"galaxy_history_id": "", "galaxy_history_id": "",
"experiments": [experiment_created_from_api.id], "experiments": [experiment_created_from_api.id],
"toolsParams": analysis_tool_params, "toolsParams": analysis_tool_params,
"galaxy_workflow_id": request.param,
}, },
format="json", format="json",
) )
...@@ -261,15 +270,17 @@ def lodscores_created_from_task_result( ...@@ -261,15 +270,17 @@ def lodscores_created_from_task_result(
mock_show_history_factory({"name": "xxxx_lod.csv", "id": "lodscores.csv"}) mock_show_history_factory({"name": "xxxx_lod.csv", "id": "lodscores.csv"})
mock_download_dataset_factory() mock_download_dataset_factory()
yield load_lod_score( 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 @pytest.fixture
def lodscores_created_from_task(lodscores_created_from_task_result): def lodscores_created_from_task(lodscores_created_from_task_result):
lodscore = LodScore.objects.get( lodscore = LodScore.objects.get(id=lodscores_created_from_task_result[2])
id=lodscores_created_from_task_result["lodscores_id"]
)
yield lodscore yield lodscore
...@@ -285,13 +296,13 @@ def peaks_created_from_task_result( ...@@ -285,13 +296,13 @@ def peaks_created_from_task_result(
mock_show_history_factory({"name": "xxxx_refine-peaks.csv", "id": "peaks.csv"}) mock_show_history_factory({"name": "xxxx_refine-peaks.csv", "id": "peaks.csv"})
mock_download_dataset_factory() mock_download_dataset_factory()
yield load_refine_peaks( 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 @pytest.fixture
def peaks_created_from_task(peaks_created_from_task_result): 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 yield peaks
...@@ -313,15 +324,13 @@ def coefficients_created_from_task_result( ...@@ -313,15 +324,13 @@ def coefficients_created_from_task_result(
) )
mock_download_dataset_factory() mock_download_dataset_factory()
yield load_coefficient( 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 @pytest.fixture
def coefficient_created_from_task(coefficients_created_from_task_result): def coefficient_created_from_task(coefficients_created_from_task_result):
coeff = Coefficient.objects.get( coeff = Coefficient.objects.get(id=coefficients_created_from_task_result[2])
id=coefficients_created_from_task_result["coefficient_id"]
)
yield coeff yield coeff
...@@ -343,13 +352,14 @@ def haplotypes_created_from_task_result( ...@@ -343,13 +352,14 @@ def haplotypes_created_from_task_result(
) )
mock_download_dataset_factory() mock_download_dataset_factory()
yield load_haplotypes( 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 @pytest.fixture
def haplotypes_created_from_task(haplotypes_created_from_task_result): 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 yield haplo
...@@ -371,13 +381,13 @@ def snps_assoc_created_from_task_result( ...@@ -371,13 +381,13 @@ def snps_assoc_created_from_task_result(
) )
mock_download_dataset_factory() mock_download_dataset_factory()
yield load_snps_association( 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 @pytest.fixture
def snps_assoc_created_from_task(snps_assoc_created_from_task_result): 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 yield snps
...@@ -400,13 +410,13 @@ def top_snps_created_from_task_result( ...@@ -400,13 +410,13 @@ def top_snps_created_from_task_result(
) )
mock_download_dataset_factory() mock_download_dataset_factory()
yield load_top_snps( 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 @pytest.fixture
def top_snps_created_from_task(top_snps_created_from_task_result): 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 yield snps
...@@ -426,7 +436,7 @@ def significance_threshold_created_from_task_result( ...@@ -426,7 +436,7 @@ def significance_threshold_created_from_task_result(
) )
mock_download_dataset_factory() mock_download_dataset_factory()
yield load_significance_threshold( 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( ...@@ -435,7 +445,7 @@ def significance_threshold_created_from_task(
significance_threshold_created_from_task_result, significance_threshold_created_from_task_result,
): ):
thresholds = LodScoreSignificanceThreshold.objects.filter( thresholds = LodScoreSignificanceThreshold.objects.filter(
id__in=significance_threshold_created_from_task_result["ids"] id__in=significance_threshold_created_from_task_result[2]
) )
yield thresholds yield thresholds
...@@ -26,6 +26,7 @@ def test_analysis_permissions( ...@@ -26,6 +26,7 @@ def test_analysis_permissions(
analysis_tool_params, analysis_tool_params,
mock_delete_history, mock_delete_history,
mock_get_history_status_in_model, mock_get_history_status_in_model,
workflow_id,
): ):
role_param = project_with_members_response[1] role_param = project_with_members_response[1]
...@@ -54,6 +55,7 @@ def test_analysis_permissions( ...@@ -54,6 +55,7 @@ def test_analysis_permissions(
"galaxy_history_id": "", "galaxy_history_id": "",
"experiments": [experiment_created_from_api.id], "experiments": [experiment_created_from_api.id],
"toolsParams": analysis_tool_params, "toolsParams": analysis_tool_params,
"galaxy_workflow_id": workflow_id,
}, },
format="json", format="json",
) )
......
...@@ -3,8 +3,10 @@ from api.tests.utils import authenticate ...@@ -3,8 +3,10 @@ from api.tests.utils import authenticate
@pytest.mark.django_db @pytest.mark.django_db
def test_coefficient_creation(coefficients_created_from_task_result): def test_coefficient_creation(
assert coefficients_created_from_task_result["status"] == "ok" 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 @pytest.mark.django_db
......
...@@ -3,8 +3,10 @@ from api.tests.utils import authenticate ...@@ -3,8 +3,10 @@ from api.tests.utils import authenticate
@pytest.mark.django_db @pytest.mark.django_db
def test_haplotype_creation(haplotypes_created_from_task_result): def test_haplotype_creation(
assert haplotypes_created_from_task_result["status"] == "ok" 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 @pytest.mark.django_db
......
...@@ -4,9 +4,12 @@ from api.tests.utils import authenticate ...@@ -4,9 +4,12 @@ from api.tests.utils import authenticate
@pytest.mark.django_db @pytest.mark.django_db
def test_significance_thresholds_creation( 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 @pytest.mark.django_db
...@@ -16,7 +19,6 @@ def test_significance_thresholds_permissions( ...@@ -16,7 +19,6 @@ def test_significance_thresholds_permissions(
project_created_from_api, project_created_from_api,
project_with_members_response, project_with_members_response,
analysis_created_from_api, analysis_created_from_api,
user_password, user_password,
significance_threshold_created_from_task, significance_threshold_created_from_task,
): ):
......
...@@ -3,8 +3,10 @@ from api.tests.utils import authenticate ...@@ -3,8 +3,10 @@ from api.tests.utils import authenticate
@pytest.mark.django_db @pytest.mark.django_db
def test_snps_assoc_creation(snps_assoc_created_from_task_result): def test_snps_assoc_creation(
assert snps_assoc_created_from_task_result["status"] == "ok" 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 @pytest.mark.django_db
......
...@@ -3,8 +3,10 @@ from api.tests.utils import authenticate ...@@ -3,8 +3,10 @@ from api.tests.utils import authenticate
@pytest.mark.django_db @pytest.mark.django_db
def test_top_snps_creation(top_snps_created_from_task_result): def test_top_snps_creation(
assert top_snps_created_from_task_result["status"] == "ok" 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 @pytest.mark.django_db
......
...@@ -37,14 +37,26 @@ def mock_show_dataset(mocker): ...@@ -37,14 +37,26 @@ def mock_show_dataset(mocker):
yield 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( def test_celery_raw_fixtures(
mock_show_job, mock_show_job,
mock_upload_file, mock_upload_file,
mock_show_dataset, mock_show_dataset,
mock_rmtree,
upload_data_id upload_data_id
# celery_app, # celery_app,
# celery_session_worker, # celery_session_worker,
): ):
res = upload_file_to_galaxy("/toto", "history_id", "auto") analysis_id = 1
assert res == upload_data_id history_id = "history_id"
res = upload_file_to_galaxy((analysis_id, history_id), "/fake-folder", "auto")
assert res[2] == upload_data_id
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment