From 353348d18c1ec6e7cdbd0d5c55ac10355971668c Mon Sep 17 00:00:00 2001 From: Richard Bruskiewich Date: Thu, 25 Apr 2024 10:31:53 -0700 Subject: [PATCH] graph-validation-tests expected output format tweaked slightly --- test_harness/run.py | 10 +- tests/example_test_outputs.py | 332 ++++++++++------------------------ 2 files changed, 101 insertions(+), 241 deletions(-) diff --git a/test_harness/run.py b/test_harness/run.py index 706b350..b449900 100644 --- a/test_harness/run.py +++ b/test_harness/run.py @@ -1,5 +1,5 @@ """Run tests through the Test Runners.""" -from typing import Optional, Tuple, List, Dict +from typing import Optional, List, Dict from collections import defaultdict import httpx import json @@ -11,10 +11,8 @@ from translator_testing_model.datamodel.pydanticmodel import ( TestAsset, TestCase, - TestObjectiveEnum, TestEnvEnum, - ComponentEnum, - TestCaseResultEnum + ComponentEnum ) from ARS_Test_Runner.semantic_test import run_semantic_test as run_ars_test @@ -414,9 +412,7 @@ async def run_tests( try: labels: List[Dict[str, str]] = list() for component, result in test_case_results.items(): - # TODO: maybe the 'graph-validation-tests' TestRunners should - # rather return a Dict with result["status"], not a Tuple? - status: str = result[0] if isinstance(result, Tuple) else result + status: str = result["status"] if "status" in result else "PASSED" # TODO: unsure if the status should be counted here (with respect to the test cases?) # or whether it should be tallied somewhere else full_report[status] += 1 diff --git a/tests/example_test_outputs.py b/tests/example_test_outputs.py index 3c1257c..04aaf2b 100644 --- a/tests/example_test_outputs.py +++ b/tests/example_test_outputs.py @@ -3,262 +3,126 @@ """ example_one_hops_test_output = { - "pks": [ - "arax", - "molepro" - ], - "results": [ - [ - { - "arax": { - "by_subject": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": { - "error.trapi.response.knowledge_graph.missing_expected_edge": { - "global": { - "TestAsset:00001|(DRUGBANK:DB01592#biolink:SmallMolecule)-[biolink:has_side_effect]->(MONDO:0011426#biolink:Disease)": None - } - } - }, - "critical": {} - } - } - }, - { - "arax": { - "inverse_by_new_subject": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": {}, - "critical": { - "critical.trapi.response.unexpected_http_code": { - "global": { - "400": None - } - } + "pks": { + "arax": "arax", + "molepro": "molepro" + }, + "results": { + "TestAsset_1-by_subject": { + "molepro": { + "status": "PASSED", + "messages": { + "info": { + "info.compliant": { + "global": None } } } - }, - { - "arax": { - "by_object": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": { - "error.trapi.response.knowledge_graph.missing_expected_edge": { - "global": { - "TestAsset:00001|(DRUGBANK:DB01592#biolink:SmallMolecule)-[biolink:has_side_effect]->(MONDO:0011426#biolink:Disease)": None - } - } - }, - "critical": {} - } - } - }, - { - "arax": { - "raise_subject_entity": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": {}, - "critical": { - "critical.trapi.request.invalid": { - "global": { - "subject 'DRUGBANK:DB01592[biolink:SmallMolecule]'": [ - { - "context": "raise_subject_entity", - "reason": "has no 'is_a' parent since it is either not an ontology term or does not map onto a parent ontology term." - } - ] - } + } + }, + "TestAsset_1-inverse_by_new_subject": { + "molepro": { + "status": "FAILED", + "messages": { + "critical": { + "critical.trapi.request.invalid": { + "global": { + "predicate 'biolink:is_active_metabolite_of'": [ + { + "context": "inverse_by_new_subject", + "reason": "is an unknown or has no inverse?" + } + ] } } } } - }, - { - "arax": { - "raise_object_entity": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": { - "error.trapi.response.knowledge_graph.missing_expected_edge": { - "global": { - "TestAsset:00001|(DRUGBANK:DB01592#biolink:SmallMolecule)-[biolink:has_side_effect]->(MONDO:0011426#biolink:Disease)": None - } - } - }, - "critical": {} - } - } - }, - { - "arax": { - "raise_object_by_subject": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": { - "error.trapi.response.knowledge_graph.missing_expected_edge": { - "global": { - "TestAsset:00001|(DRUGBANK:DB01592#biolink:SmallMolecule)-[biolink:has_side_effect]->(MONDO:0011426#biolink:Disease)": None - } - } - }, - "critical": {} - } - } - }, - { - "arax": { - "raise_predicate_by_subject": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": { - "error.trapi.response.knowledge_graph.missing_expected_edge": { - "global": { - "TestAsset:00001|(DRUGBANK:DB01592#biolink:SmallMolecule)-[biolink:has_side_effect]->(MONDO:0011426#biolink:Disease)": None - } - } - }, - "critical": {} - } - } } - ], - [ - { - "molepro": { - "by_subject": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": { - "error.trapi.response.knowledge_graph.missing_expected_edge": { - "global": { - "TestAsset:00001|(DRUGBANK:DB01592#biolink:SmallMolecule)-[biolink:has_side_effect]->(MONDO:0011426#biolink:Disease)": None - } - } - }, - "critical": {} - } - } - }, - { - "molepro": { - "inverse_by_new_subject": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": { - "error.trapi.response.knowledge_graph.missing_expected_edge": { - "global": { - "TestAsset:00001|(DRUGBANK:DB01592#biolink:SmallMolecule)-[biolink:has_side_effect]->(MONDO:0011426#biolink:Disease)": None - } + }, + "TestAsset_1-by_object": { + "molepro": { + "status": "FAILED", + "messages": { + "error": { + "error.trapi.response.knowledge_graph.missing_expected_edge": { + "global": { + "TestAsset_1|(CHEBI:58579#biolink:SmallMolecule)-[biolink:is_active_metabolite_of]->(UniProtKB:Q9NQ88#biolink:Protein)": None } - }, - "critical": {} - } - } - }, - { - "molepro": { - "by_object": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": { - "error.trapi.response.knowledge_graph.missing_expected_edge": { - "global": { - "TestAsset:00001|(DRUGBANK:DB01592#biolink:SmallMolecule)-[biolink:has_side_effect]->(MONDO:0011426#biolink:Disease)": None - } - } - }, - "critical": {} + } } } - }, - { - "molepro": { - "raise_subject_entity": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": {}, - "critical": { - "critical.trapi.request.invalid": { - "global": { - "subject 'DRUGBANK:DB01592[biolink:SmallMolecule]'": [ - { - "context": "raise_subject_entity", - "reason": "has no 'is_a' parent since it is either not an ontology term or does not map onto a parent ontology term." - } - ] - } + } + }, + "TestAsset_1-raise_subject_entity": { + "molepro": { + "status": "FAILED", + "messages": { + "critical": { + "critical.trapi.request.invalid": { + "global": { + "subject 'CHEBI:58579[biolink:SmallMolecule]'": [ + { + "context": "raise_subject_entity", + "reason": "has no 'is_a' parent since it is either not an ontology term or does not map onto a parent ontology term." + } + ] } } } } - }, - { - "molepro": { - "raise_object_entity": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": { - "error.trapi.response.knowledge_graph.missing_expected_edge": { - "global": { - "TestAsset:00001|(DRUGBANK:DB01592#biolink:SmallMolecule)-[biolink:has_side_effect]->(MONDO:0011426#biolink:Disease)": None - } + } + }, + "TestAsset_1-raise_object_entity": { + "molepro": { + "status": "FAILED", + "messages": { + "critical": { + "critical.trapi.request.invalid": { + "global": { + "object 'UniProtKB:Q9NQ88[biolink:Protein]'": [ + { + "context": "raise_object_entity", + "reason": "has no 'is_a' parent since it is either not an ontology term or does not map onto a parent ontology term." + } + ] } - }, - "critical": {} + } } } - }, - { - "molepro": { - "raise_object_by_subject": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": { - "error.trapi.response.knowledge_graph.missing_expected_edge": { - "global": { - "TestAsset:00001|(DRUGBANK:DB01592#biolink:SmallMolecule)-[biolink:has_side_effect]->(MONDO:0011426#biolink:Disease)": None - } + } + }, + "TestAsset_1-raise_object_by_subject": { + "molepro": { + "status": "FAILED", + "messages": { + "error": { + "error.trapi.response.knowledge_graph.missing_expected_edge": { + "global": { + "TestAsset_1|(CHEBI:58579#biolink:SmallMolecule)-[biolink:is_active_metabolite_of]->(UniProtKB:Q9NQ88#biolink:Protein)": None } - }, - "critical": {} + } } } - }, - { - "molepro": { - "raise_predicate_by_subject": { - "info": {}, - "skipped": {}, - "warning": {}, - "error": { - "error.trapi.response.knowledge_graph.missing_expected_edge": { - "global": { - "TestAsset:00001|(DRUGBANK:DB01592#biolink:SmallMolecule)-[biolink:has_side_effect]->(MONDO:0011426#biolink:Disease)": None - } + } + }, + "TestAsset_1-raise_predicate_by_subject": { + "molepro": { + "status": "FAILED", + "messages": { + "critical": { + "critical.trapi.request.invalid": { + "global": { + "predicate 'biolink:is_active_metabolite_of'": [ + { + "context": "raise_predicate_by_subject", + "reason": "has no 'is_a' parent" + } + ] } - }, - "critical": {} + } } } } - ] - ] -} \ No newline at end of file + } + } +}