Add test coverage for history advanced filters

When dealing with archived histories.
This commit is contained in:
davelopez
2024-03-28 11:14:25 +01:00
parent f5e07b11f0
commit cd9c84d61a
+34
View File
@@ -304,6 +304,40 @@ class TestHistoriesApi(ApiTestCase, BaseHistories):
index_response = self._get("histories", data=data).json()
assert len(index_response) == 1
archived_history_id = self._create_history(f"Archived history_{uuid4()}")["id"]
name_contains = "history"
data = dict(search=name_contains, show_published=False)
index_response = self._get("histories", data=data).json()
assert len(index_response) == 4
# Archived histories should not be included in the index
self.dataset_populator.archive_history(archived_history_id)
data = dict(search=name_contains, show_published=False)
index_response = self._get("histories", data=data).json()
assert len(index_response) == 3
archived_public_history_id = self._create_history(f"Public Archived history_{uuid4()}")["id"]
self._update(archived_public_history_id, {"published": True})
self.dataset_populator.archive_history(archived_public_history_id)
data = dict(search=name_contains, show_published=False)
index_response = self._get("histories", data=data).json()
assert len(index_response) == 3
name_contains = "Archived"
data = dict(search=name_contains, show_published=False)
index_response = self._get("histories", data=data).json()
assert len(index_response) == 0
# Archived public histories should be included when filtering by published
data = dict(search="is:published")
index_response = self._get("histories", data=data).json()
assert len(index_response) == 2
name_contains = "Archived"
data = dict(search=name_contains, show_published=True)
index_response = self._get("histories", data=data).json()
assert len(index_response) == 1
def test_delete(self):
# Setup a history and ensure it is in the index
history_id = self._create_history("TestHistoryForDelete")["id"]