Commit 29c51f30 authored by David Mendez's avatar David Mendez
Browse files

Fix unit tests

parent 86363e7d
......@@ -73,7 +73,7 @@ class TestIDsLoader(unittest.TestCase):
"must_not": [
{
"terms": {
from_property: selection_description['exceptions']
'_id': selection_description['exceptions']
}
}
]
......@@ -104,7 +104,7 @@ class TestIDsLoader(unittest.TestCase):
"bool": {
"filter": [{
"terms": {
from_property: selection_description['exceptions']
'_id': selection_description['exceptions']
}
}],
}
......@@ -116,70 +116,3 @@ class TestIDsLoader(unittest.TestCase):
self.assertDictEqual(ids_query_must_be, ids_query_got,
msg='The query was not generated correctly when selecting no items except some!')
def test_generates_query_to_get_ids_when_selecting_all_except_some_selecting_by_id(self):
"""
test that it generates the required query when selected all items in dataset except some and the items
are identified by _id
"""
es_query = load_sample_query('sample_query_0.json')
selection_description = {
"selectionMode": "allItemsExcept",
"exceptions": ['CHEMBL64___999', 'CHEMBL1366___152']
}
from_property = 'drug_warning.molecule_chembl_id'
id_property = '_id'
ids_query_must_be = {
"query": {
"bool": {
"filter": [],
"should": [],
"must_not": [
{
"terms": {
id_property: selection_description['exceptions']
}
}
]
}
},
"_source": [from_property],
}
ids_query_got = ids_loader.get_ids_query(es_query, selection_description, from_property, id_property)
self.assertDictEqual(ids_query_must_be, ids_query_got,
msg='The query was not generated correctly when selecting all items except some using'
' a different id property!')
def test_generates_query_to_get_ids_when_selecting_none_except_some_selecting_by_id(self):
"""
test that it generates the required query when selecting none except zone selecting by _id
"""
es_query = load_sample_query('sample_query_0.json')
selection_description = {
"selectionMode": "noItemsExcept",
"exceptions": ['CHEMBL64___999', 'CHEMBL1366___152']
}
from_property = 'drug_warning.molecule_chembl_id'
id_property = '_id'
ids_query_must_be = {
"query": {
"bool": {
"filter": [{
"terms": {
id_property: selection_description['exceptions']
}
}],
}
},
"_source": [from_property],
}
ids_query_got = ids_loader.get_ids_query(es_query, selection_description, from_property, id_property)
self.assertDictEqual(ids_query_must_be, ids_query_got,
msg='The query was not generated correctly when selecting no items except some!')
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