Skip to content

Commit

Permalink
Improve csv test units
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledk2 committed Dec 28, 2024
1 parent 1ae52a0 commit 499a310
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
17 changes: 17 additions & 0 deletions omero_search_engine/validation/results_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,3 +1346,20 @@ def check_container_keys_vakues():
search_omero_app.logger.info(
"No results returned from searchengine"
)


def test_csv_data_sources(data_source="test_csv"):
from unit_tests.test_data import csv_test_data

is_valid = True
for data in csv_test_data:
results = simple_search(
data["key"], data["value"], "equals", None, None, "image", None, data_source
)
if results.get("results").get("size") != data["no_results"]:
search_omero_app.logger.info(
"This data record (%s) is not valid, returned results is %s"
% (data, results.get("results").get("size"))
)
is_valid = False
return is_valid
12 changes: 3 additions & 9 deletions unit_tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,14 @@
get_data_sources,
)

from omero_search_engine.api.v1.resources.query_handler import (
simple_search,
)

from omero_search_engine.cache_functions.elasticsearch.elasticsearch_templates import ( # noqa
image_template,
key_values_resource_cache_template,
)

from omero_search_engine.validation.results_validator import (
Validator,
test_csv_data_sources,
# check_number_images_sql_containers_using_ids,
)
from omero_search_engine.cache_functions.elasticsearch.transform_data import (
Expand Down Expand Up @@ -388,10 +385,8 @@ def test_csv_data_query(self):
"""
Test available data sources
"""
results = simple_search(
"organism", "homo sapiens", "equals", None, None, "image", None, "test_csv"
)
self.assertEqual(results.get("results").get("size"), 15756)
is_valid = test_csv_data_sources()
self.assertTrue(is_valid)

# def test_add_delete_es_index(self):
# '''
Expand All @@ -413,5 +408,4 @@ def test_log_in_log_out(self):


if __name__ == "__main__":

unittest.main()
5 changes: 5 additions & 0 deletions unit_tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,8 @@
images_keys = ["cell line", "gene symbol"]

images_value_parts = ["he", "pr"]

csv_test_data = [
{"key": "organism", "value": "homo sapiens", "no_results": 15756},
{"key": "gene symbol", "value": "pcnt", "no_results": 1484},
]

0 comments on commit 499a310

Please sign in to comment.