From 163f43a1eebfea7b97f7b30e9e2a036aeebfe658 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 5 Oct 2022 11:02:37 +0300 Subject: mechanical-rob: Fix tests that were checking for the wrong thing --- test/requests/correlation_tests.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/requests/correlation_tests.py b/test/requests/correlation_tests.py index 9d106013..0915dc68 100644 --- a/test/requests/correlation_tests.py +++ b/test/requests/correlation_tests.py @@ -1,4 +1,5 @@ import sys +import html import requests from lxml.html import parse from link_checker import check_page @@ -58,11 +59,20 @@ def check_tissue_correlations(baseurl, base_data): "corr_type": "tissue", "location_type": "gene", } - top_n_message = "The top 100 correlations ranked by the Tissue Correlation" result = do_request(f"{baseurl}/corr_compute", data) + assert result.status_code == 200 - assert (result.text.find(f"Values of record {base_data['trait_id']}") >= 0), result.text - assert (result.text.find(top_n_message) >= 0), result.text + if (data["trait_id"] == "1442370_at" + and data["corr_dataset"] in ("BXDPublish",)): + top_n_message = ( + "It is not possible to compute the 'Tissue' correlations between " + f"trait '{data['trait_id']}' and the data") + else: + top_n_message = "The top 100 correlations ranked by the Tissue Correlation" + assert (result.text.find(f"Values of record {base_data['trait_id']}") >= 0), result.text + + assert (html.unescape(result.text).find(top_n_message) >= 0), ( + f"NOT FOUND: {top_n_message}") def check_lit_correlations(baseurl, base_data): data = { @@ -70,11 +80,20 @@ def check_lit_correlations(baseurl, base_data): "corr_type": "lit", "corr_return_results": "200" } - top_n_message = "The top 200 correlations ranked by the Literature Correlation" result = do_request(f"{baseurl}/corr_compute", data) + assert result.status_code == 200 - assert (result.text.find(f"Values of record {base_data['trait_id']}") >= 0), result.text - assert (result.text.find(top_n_message) >= 0), result.text + if (data["trait_id"] == "1442370_at" + and data["corr_dataset"] in ("BXDPublish",)): + top_n_message = ( + "It is not possible to compute the 'Literature' correlations " + f"between trait '{data['trait_id']}' and the data") + else: + top_n_message = "The top 200 correlations ranked by the Literature Correlation" + assert (result.text.find(f"Values of record {base_data['trait_id']}") >= 0), result.text + + assert (html.unescape(result.text).find(top_n_message) >= 0), ( + f"NOT FOUND: {top_n_message}") def check_correlations(args_obj, parser): print("") -- cgit v1.2.3