diff --git a/tests/views/search_tests.py b/tests/views/search_tests.py index bcfab6e2328..a52f6bf306c 100644 --- a/tests/views/search_tests.py +++ b/tests/views/search_tests.py @@ -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 @@ -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, @@ -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, @@ -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"}, @@ -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 [