Commit 65196a1c authored by David Mendez's avatar David Mendez
Browse files

Entities join: Add more cases to the joins

parent 49d6a58d
......@@ -40,4 +40,5 @@ def get_link_to_related_items():
selection_description, previous_hash)
return jsonify(json_response)
except entities_join_service.EntitiesJoinServiceError as error:
app_logging.debug(str(error))
abort(500, f'Internal server error: {str(error)}')
......@@ -70,6 +70,7 @@ def create_simple_query_generator(destination_property):
:param destination_property: property to use to build the query
:return: a function to be used to build the join query
"""
def join_function(ids):
"""
:param ids: ids of the items matches
......@@ -77,11 +78,20 @@ def create_simple_query_generator(destination_property):
"""
ids_clauses = " OR ".join([f'"{item_id}"' for item_id in ids])
return f'{destination_property}({ids_clauses})'
return join_function
JOIN_PROPERTIES = {
'from': {
PossibleDestinationEntities.CHEMBL_COMPOUNDS: {
'to': {
PossibleDestinationEntities.CHEMBL_ACTIVITIES: {
'origin_property': 'molecule_chembl_id',
'destination_query_generator': create_simple_query_generator('molecule_chembl_id')
}
}
},
PossibleOriginEntities.CHEMBL_DRUG_WARNINGS: {
'to': {
PossibleDestinationEntities.CHEMBL_ACTIVITIES: {
......
{
"query": {
"bool": {
"must": [
{
"query_string": {
"analyze_wildcard": true,
"query": "*"
}
}
],
"filter": [
[
{
"bool": {
"should": [
{
"term": {
"molecule_type": "Oligosaccharide"
}
}
]
}
}
]
]
}
}
}
\ No newline at end of file
# pylint: disable=import-error
"""
Module that tests the endpoints to do joins among entities from drug warnings to drug indications
"""
from specific_tests import utils
from specific_tests.entities_join import utils as entities_join_utils
def run_test(server_base_url, delayed_jobs_server_base_path):
"""
Tests doing a join among different entities from drug warnings to drug mechanisms
:param server_base_url: base url of the running server. E.g. http://127.0.0.1:5000
:param delayed_jobs_server_base_path: base path for the delayed_jobs
"""
print('-------------------------------------------')
print('Testing joins among entities selecting all none except')
print('-------------------------------------------')
dataset_query = utils.load_json_data('functional_tests/specific_tests/data/entities_join_query_1.json')
selection_description = {"selectionMode": "allItemsExcept", "exceptions": []}
entities_join_utils.test_entities_join(dataset_query, selection_description, server_base_url,
entity_from='CHEMBL_COMPOUNDS', entity_to='CHEMBL_ACTIVITIES')
......@@ -2,7 +2,8 @@
Module that runs all the tests related to the entities join
"""
from specific_tests.entities_join import fun_test_entities_join_0, fun_test_entities_join_1, fun_test_entities_join_2, \
fun_test_entities_join_3, fun_test_entities_join_4, fun_test_entities_join_5
fun_test_entities_join_3, fun_test_entities_join_4, fun_test_entities_join_5, fun_test_entities_join_6, \
fun_test_entities_join_7
def run_test(server_base_url, delayed_jobs_server_base_path):
......@@ -12,5 +13,6 @@ def run_test(server_base_url, delayed_jobs_server_base_path):
:param delayed_jobs_server_base_path: base path for the delayed_jobs
"""
for test_module in [fun_test_entities_join_0, fun_test_entities_join_1, fun_test_entities_join_2,
fun_test_entities_join_3, fun_test_entities_join_4, fun_test_entities_join_5]:
fun_test_entities_join_3, fun_test_entities_join_4, fun_test_entities_join_5,
fun_test_entities_join_6, fun_test_entities_join_7]:
test_module.run_test(server_base_url, delayed_jobs_server_base_path)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment