Skip to content

Commit

Permalink
Fix the broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maximusunc committed Oct 10, 2024
1 parent 3fc9831 commit 3d2e3be
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 59 deletions.
28 changes: 14 additions & 14 deletions tests/helpers/redisMock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"maturity": "development",
"operations": [
{
"subject_category": "biolink:ChemicalSubstance",
"subject_category": "biolink:SmallMolecule",
"predicate": "biolink:treats",
"object_category": "biolink:Disease",
},
],
"details": {
"preferred_prefixes": {
"biolink:Disease": ["MONDO", "DOID"],
"biolink:ChemicalSubstance": ["CHEBI", "MESH"],
"biolink:SmallMolecule": ["CHEBI", "MESH"],
"biolink:PhenotypicFeature": ["HP"],
},
},
Expand All @@ -46,17 +46,17 @@
"object_category": "biolink:Disease",
},
{
"subject_category": "biolink:ChemicalSubstance",
"subject_category": "biolink:SmallMolecule",
"predicate": "biolink:treats",
"object_category": "biolink:Disease",
},
{
"subject_category": "biolink:ChemicalSubstance",
"subject_category": "biolink:SmallMolecule",
"predicate": "biolink:genetically_interacts_with",
"object_category": "biolink:Disease",
},
{
"subject_category": "biolink:ChemicalSubstance",
"subject_category": "biolink:SmallMolecule",
"predicate": "biolink:treats",
"object_category": "biolink:PhenotypicFeature",
},
Expand All @@ -69,7 +69,7 @@
"details": {
"preferred_prefixes": {
"biolink:Disease": ["MONDO", "DOID"],
"biolink:ChemicalSubstance": ["CHEBI", "MESH"],
"biolink:SmallMolecule": ["CHEBI", "MESH"],
"biolink:PhenotypicFeature": ["HP"],
},
},
Expand All @@ -95,15 +95,15 @@
"object_category": "biolink:Disease",
},
{
"subject_category": "biolink:ChemicalSubstance",
"predicate": "biolink:ameliorates",
"subject_category": "biolink:SmallMolecule",
"predicate": "biolink:ameliorates_condition",
"object_category": "biolink:Gene",
},
],
"details": {
"preferred_prefixes": {
"biolink:Disease": ["MONDO", "DOID"],
"biolink:ChemicalSubstance": ["CHEBI", "MESH"],
"biolink:SmallMolecule": ["CHEBI", "MESH"],
"biolink:PhenotypicFeature": ["HP"],
},
},
Expand All @@ -114,15 +114,15 @@
"maturity": "development",
"operations": [
{
"subject_category": "biolink:Vitamin",
"subject_category": "biolink:Disease",
"predicate": "biolink:treats",
"object_category": "biolink:Disease",
"object_category": "biolink:NucleicAcidEntity",
},
],
"details": {
"preferred_prefixes": {
"biolink:Disease": ["MONDO", "DOID"],
"biolink:ChemicalSubstance": ["CHEBI", "MESH"],
"biolink:SmallMolecule": ["CHEBI", "MESH"],
"biolink:PhenotypicFeature": ["HP"],
},
},
Expand All @@ -133,15 +133,15 @@
"maturity": "development",
"operations": [
{
"subject_category": "biolink:ChemicalSubstance",
"subject_category": "biolink:SmallMolecule",
"predicate": "biolink:not_a_real_predicate",
"object_category": "biolink:Disease",
},
],
"details": {
"preferred_prefixes": {
"biolink:Disease": ["MONDO", "DOID"],
"biolink:ChemicalSubstance": ["CHEBI", "MESH"],
"biolink:SmallMolecule": ["CHEBI", "MESH"],
"biolink:PhenotypicFeature": ["HP"],
},
},
Expand Down
20 changes: 10 additions & 10 deletions tests/test_kp_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def test_kp_response_empty_message(monkeypatch, httpx_mock: HTTPXMock):
n0(( categories[] biolink:Drug ))
n0(( ids[] CHEBI:6801 ))
n0-- biolink:treats -->n1
n1(( category biolink:Disease ))
n1(( categories[] biolink:Disease ))
"""
)

Expand Down Expand Up @@ -66,12 +66,12 @@ async def test_kp_response_empty_message_pinned_two_hop(
"""
# mock the return of the kp registry from redis
monkeypatch.setattr(redis.asyncio, "Redis", redisMock)
httpx_mock.add_response(url="http://kp1/query", json={"message": {}})
httpx_mock.add_response(url="http://kp2/query", json={"message": {}})
QGRAPH = query_graph_from_string(
"""
n0(( ids[] MONDO:1 ))
n0-- biolink:related_to -->n1
n1(( category biolink:Gene ))
n1(( categories[] biolink:Gene ))
n1-- biolink:related_to -->n2
n2(( ids[] MONDO:2 ))
Expand Down Expand Up @@ -108,7 +108,7 @@ async def test_kp_500(monkeypatch, httpx_mock: HTTPXMock):
QGRAPH = query_graph_from_string(
"""
n0(( ids[] CHEBI:6801 ))
n0(( categories[] biolink:ChemicalSubstance ))
n0(( categories[] biolink:SmallMolecule ))
n1(( categories[] biolink:Disease ))
n0-- biolink:treats -->n1
"""
Expand Down Expand Up @@ -145,7 +145,7 @@ async def test_kp_not_trapi(monkeypatch, httpx_mock: HTTPXMock):
n0(( categories[] biolink:Disease ))
n0(( ids[] MONDO:0005737 ))
n0-- biolink:treated_by -->n1
n1(( category biolink:Drug ))
n1(( categories[] biolink:Drug ))
"""
)

Expand Down Expand Up @@ -181,10 +181,10 @@ async def test_kp_no_kg(monkeypatch, httpx_mock: HTTPXMock):
)
QGRAPH = query_graph_from_string(
"""
n0(( categories[] biolink:ChemicalSubstance ))
n0(( categories[] biolink:SmallMolecule ))
n0(( ids[] CHEBI:0001 ))
n0-- biolink:treats -->n1
n1(( category biolink:Disease ))
n1(( categories[] biolink:Disease ))
"""
)

Expand Down Expand Up @@ -217,10 +217,10 @@ async def test_kp_response_no_qg(monkeypatch, httpx_mock: HTTPXMock):
httpx_mock.add_response(url="http://kp1/query", json=mock_responses.kp_response)
QGRAPH = query_graph_from_string(
"""
n0(( categories[] biolink:ChemicalSubstance ))
n0(( categories[] biolink:SmallMolecule ))
n0(( ids[] CHEBI:6801 ))
n0-- biolink:treats -->n1
n1(( category biolink:Disease ))
n1(( categories[] biolink:Disease ))
"""
)

Expand Down Expand Up @@ -302,7 +302,7 @@ async def test_constraint_error(monkeypatch, httpx_mock: HTTPXMock):
QGRAPH = query_graph_from_string(
"""
n0(( ids[] CHEBI:6801 ))
n0(( categories[] biolink:ChemicalSubstance ))
n0(( categories[] biolink:SmallMolecule ))
n0-- biolink:treats -->n1
n1(( categories[] biolink:Disease ))
"""
Expand Down
12 changes: 6 additions & 6 deletions tests/test_query_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def test_plan_loop(monkeypatch):
n0(( ids[] MONDO:0008114 ))
n0(( categories[] biolink:Disease ))
n1(( categories[] biolink:PhenotypicFeature ))
n2(( categories[] biolink:ChemicalSubstance ))
n2(( categories[] biolink:SmallMolecule ))
n0-- biolink:has_phenotype -->n1
n2-- biolink:treats -->n0
n2-- biolink:treats -->n1
Expand Down Expand Up @@ -370,7 +370,7 @@ async def test_predicate_fanout(monkeypatch):
monkeypatch.setattr(redis.asyncio, "Redis", redisMock)
qg = {
"nodes": {
"a": {"categories": ["biolink:ChemicalSubstance"], "ids": ["CHEBI:34253"]},
"a": {"categories": ["biolink:SmallMolecule"], "ids": ["CHEBI:34253"]},
"b": {"categories": ["biolink:Gene"]},
},
"edges": {
Expand Down Expand Up @@ -436,7 +436,7 @@ async def test_subpredicate(monkeypatch):
monkeypatch.setattr(redis.asyncio, "Redis", redisMock)
qg = {
"nodes": {
"a": {"categories": ["biolink:ChemicalSubstance"], "ids": ["CHEBI:34253"]},
"a": {"categories": ["biolink:SmallMolecule"], "ids": ["CHEBI:34253"]},
"b": {"categories": ["biolink:Disease"]},
},
"edges": {
Expand Down Expand Up @@ -472,8 +472,8 @@ async def test_solve_double_subclass(monkeypatch):
qg = QueryGraph.parse_obj(qg)

plan, kps = await generate_plan(qg, {}, logger=logging.getLogger())
assert plan == {"n0n1": ["infores:kp1"]}
assert "infores:kp1" in kps
assert plan == {"n0n1": ["infores:kp2"]}
assert "infores:kp2" in kps


@pytest.mark.asyncio
Expand All @@ -488,7 +488,7 @@ async def test_pinned_to_pinned(monkeypatch):
n0(( ids[] MONDO:1 ))
n0(( categories[] biolink:Disease ))
n1(( ids[] CHEBI:1 ))
n1(( categories[] biolink:Vitamin ))
n1(( categories[] biolink:NucleicAcidEntity ))
n0-- biolink:related_to -->n1
"""
)
Expand Down
Loading

0 comments on commit 3d2e3be

Please sign in to comment.