Skip to content

Commit

Permalink
add test_ids_filter to search_tests, re #11579
Browse files Browse the repository at this point in the history
  • Loading branch information
whatisgalen committed Oct 28, 2024
1 parent bcc79bf commit d2af643
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tests/views/search_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""

import json
import uuid

from tests.base_test import ArchesTestCase
from tests.utils.search_test_utils import sync_es, get_response_json
Expand Down Expand Up @@ -134,7 +135,11 @@ def setUpTestData(cls):
cls.conceptid = response_json["subconcepts"][0]["id"]

# add resource instance with only a cultural period defined
cls.cultural_period_resource = Resource(graph_id=cls.search_model_graphid)
cls.cultural_period_resourceid = str(uuid.uuid4())
cls.cultural_period_resource = Resource(
graph_id=cls.search_model_graphid,
resourceinstanceid=cls.cultural_period_resourceid,
)
tile = Tile(
data={cls.search_model_cultural_period_nodeid: [valueid]},
nodegroup_id=cls.search_model_cultural_period_nodeid,
Expand All @@ -143,7 +148,10 @@ def setUpTestData(cls):
cls.cultural_period_resource.save()

# add resource instance with a creation and destruction date defined
cls.date_resource = Resource(graph_id=cls.search_model_graphid)
cls.date_resourceid = str(uuid.uuid4())
cls.date_resource = Resource(
graph_id=cls.search_model_graphid, resourceinstanceid=cls.date_resourceid
)
tile = Tile(
data={cls.search_model_creation_date_nodeid: "1941-01-01"},
nodegroup_id=cls.search_model_creation_date_nodeid,
Expand All @@ -166,8 +174,10 @@ def setUpTestData(cls):
cls.date_resource.save()

# add resource instance with a creation date and a cultural period defined
cls.date_and_cultural_period_resourceid = str(uuid.uuid4())
cls.date_and_cultural_period_resource = Resource(
graph_id=cls.search_model_graphid
graph_id=cls.search_model_graphid,
resourceinstanceid=cls.date_and_cultural_period_resourceid,
)
tile = Tile(
data={cls.search_model_creation_date_nodeid: "1942-01-01"},
Expand Down Expand Up @@ -946,6 +956,12 @@ def test_custom_resource_index(self):
response_json = get_response_json(self.client, query=query)
self.assertEqual(response_json["results"]["hits"]["total"]["value"], 0)

def test_ids_filter(self):
ids = [self.cultural_period_resourceid, self.date_resourceid]
query = {"ids": ids}
response_json = get_response_json(self.client, query=query)
self.assertEqual(response_json["results"]["hits"]["total"]["value"], 2)


def extract_pks(response_json):
return [
Expand Down

0 comments on commit d2af643

Please sign in to comment.