Skip to content

Commit

Permalink
updating overlay connect knodes test
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDietzMorris committed Oct 4, 2024
1 parent 59f88a3 commit 5e9a964
Showing 1 changed file with 49 additions and 100 deletions.
149 changes: 49 additions & 100 deletions PLATER/tests/test_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,43 @@ def supports_apoc(self):
return True

async def run_apoc_cover(self, idlist):
return [{
'result': [
{
'subject': 'NODE:0',
'object': 'NODE:2',
'predicate': 'biolink:related_to',
'edge': {
'id': 'SUPPORT_EDGE_KG_ID_1',
'predicate': 'biolink:related_to',
'subject': 'NODE:0',
'object': 'NODE:2',
'attr_1': [],
'attr_2': {}
}
}, {
'subject': 'NODE:00',
'object': 'NODE:22',
'predicate': 'biolink:related_to',
'edge': {
'predicate': 'biolink:related_to',
'id': 'SUPPORT_EDGE_KG_ID_2',
'subject': 'NODE:00',
'object': 'NODE:22',
'attr_1': [],
'attr_2': {}
}
}, { # Edge relating two nodes from different answers
# we should expect this NOT to be in response.
'subject': 'NODE:0',
'object': 'NODE:22',
'predicate': 'biolink:related_to',
'edge': {
'subject': 'NODE:0',
'object': 'NODE:22',
'predicate': 'biolink:related_to',
'id': 'SUPPORT_EDGE_KG_ID_3'
}
}
]
}]
return {
"SUPPORT_EDGE_KG_ID_1": {
"subject": "NODE:0",
"predicate": "biolink:related_to",
"object": "NODE:2",
"attributes": [
{"original_attribute_name": "attr_1",
"value": [],
"attribute_type_id": "biolink:Attribute",
"value_type_id": "EDAM:data_0006"},
{"original_attribute_name": "attr_2",
"value": 1,
"attribute_type_id": "biolink:Attribute",
"value_type_id": "EDAM:data_0006"}]
},
"SUPPORT_EDGE_KG_ID_2": {
"subject": "NODE:00",
"predicate": "biolink:related_to",
"object": "NODE:22",
"attributes": [
{"original_attribute_name": "attr_1",
"value": [],
"attribute_type_id": "biolink:Attribute",
"value_type_id": "EDAM:data_0006"},
{"original_attribute_name": "attr_2",
"value": 1,
"attribute_type_id": "biolink:Attribute",
"value_type_id": "EDAM:data_0006"}]
},
"SUPPORT_EDGE_KG_ID_3": {
"subject": "NODE:0",
"predicate": "biolink:related_to",
"object": "NODE:22",
"attributes": []
},

}

return MockGI()

Expand All @@ -65,65 +62,17 @@ def supports_apoc(self):

@pytest.fixture()
def reasoner_json():
return {
# Although this is not particularly useful in testing...
'query_graph': {
'nodes': {
'n0': {'type': 'type'},
'n1': {'type': 'type'},
'n2': {'type': 'type'}
},
'edges':{
'e0': {'subject': 'n0', 'object': 'n1'},
'e1': {'subject': 'n1', 'object': 'n2'},
}
},
# Knowledge_graph Here also we don't really care about what was in
# kg
'knowledge_graph':
{
'nodes': {},
'edges': {}
},
'results': [
{
'node_bindings': {
'n0': [{'id': 'NODE:0'}],
'n1': [{'id': 'NODE:1'}],
'n2': [{'id': 'NODE:2'}],
},
'edge_bindings': {
'e0': [{'id': 'EDGE:0'}],
'e1': [{'id': 'EDGE:1'}],
'e2': [{'id': 'EDGE:2'}]
}
},
{
'node_bindings': {
'n0': [{'id': 'NODE:00'}],
'n1': [{'id': 'NODE:11'}],
'n2': [{'id': 'NODE:22'}],
},
'edge_bindings': {
'e0': [{'id': 'EDGE:00'}],
'e1': [{'id': 'EDGE:11'}],
'e2': [{'id': 'EDGE:22'}]
}
},
{
'node_bindings': {
'n0': [{'id': 'NODE:000'}],
'n1': [{'id': 'NODE:111'}],
'n2': [{'id': 'NODE:222'}],
},
'edge_bindings': {
'e0': [{'id': 'EDGE:000'}],
'e1': [{'id': 'EDGE:111'}],
'e2': [{'id': 'EDGE:222'}]
},
}
]
}
return \
{"query_graph":{"nodes":{"n0":{"type":"type"},"n1":{"type":"type"},"n2":{"type":"type"}},
"edges":{"e0":{"subject":"n0","object":"n1"},"e1":{"subject":"n1","object":"n2"}}},
"knowledge_graph":{"nodes":{},"edges":{}},
"results":[
{"analyses":[{"edge_bindings":{"e0":[{"id":"EDGE:0"}],"e1":[{"id":"EDGE:1"}],"e2":[{"id":"EDGE:2"}]}}],
"node_bindings":{"n0":[{"id":"NODE:0"}],"n1":[{"id":"NODE:1"}],"n2":[{"id":"NODE:2"}]}},
{"analyses":[{"edge_bindings":{"e0":[{"id":"EDGE:00"}],"e1":[{"id":"EDGE:11"}],"e2":[{"id":"EDGE:22"}]}}],
"node_bindings":{"n0":[{"id":"NODE:00"}],"n1":[{"id":"NODE:11"}],"n2":[{"id":"NODE:22"}]}},
{"analyses":[{"edge_bindings":{"e0":[{"id":"EDGE:000"}],"e1":[{"id":"EDGE:111"}],"e2":[{"id":"EDGE:222"}]}}],
"node_bindings":{"n0":[{"id":"NODE:000"}],"n1":[{"id":"NODE:111"}],"n2":[{"id":"NODE:222"}]}}]}


def get_kg_ids(bindings):
Expand All @@ -147,7 +96,7 @@ def test_overlay_adds_support_bindings(graph_interface_apoc_supported, reasoner_
for answer in response['results']:
node_bindings = answer['node_bindings']
all_node_ids = get_kg_ids(node_bindings)
edge_bindings = answer['edge_bindings']
edge_bindings = answer['analyses'][0]['edge_bindings']
all_edge_kg_ids = get_kg_ids(edge_bindings)
if ('NODE:0' in all_node_ids and 'NODE:2' in all_node_ids) \
or ('NODE:00' in all_node_ids and 'NODE:22' in all_node_ids):
Expand Down

0 comments on commit 5e9a964

Please sign in to comment.