From 24063e5be2d9813e01f3507eccca8303abc3da0c Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Mon, 26 Feb 2024 17:33:30 +0000 Subject: [PATCH] Fix ``test_index_advanced_filter`` API test re-running At the end of this test one history is made public. So, when re-running the API tests locally without wiping the database, the public history was also included in the results from the searches, causing the following error: ``` name_contains = "history" query = f"?search={name_contains}" index_response = self._get(f"histories{query}").json() > assert len(index_response) == 3 E AssertionError: assert 4 == 3 E + where 4 = len([{'annotation': None, 'archived': False, 'contents_url': '/api/histories/3393d74dbae390cc/contents', 'count': 0, ...}, {'annotation': None, 'archived': False, 'contents_url': '/api/histories/8cf91205f2f737f4/contents', 'count': 0, ...}, {'annotation': None, 'archived': False, 'contents_url': '/api/histories/b5065b03be4c41dc/contents', 'count': 0, ...}, {'annotation': None, 'archived': False, 'contents_url': '/api/histories/d9abeb98649a6a7e/contents', 'count': 0, ...}]) lib/galaxy_test/api/test_histories.py:194: AssertionError ``` Similarly, in the last part of the test the number of published histories was growing at each re-run. Also removed a redundant test. --- lib/galaxy_test/api/test_histories.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/galaxy_test/api/test_histories.py b/lib/galaxy_test/api/test_histories.py index b891681db85b..e263423b2b58 100644 --- a/lib/galaxy_test/api/test_histories.py +++ b/lib/galaxy_test/api/test_histories.py @@ -189,31 +189,26 @@ def test_index_advanced_filter(self): self._delete(f"histories/{history_1}") name_contains = "history" - query = f"?search={name_contains}" - index_response = self._get(f"histories{query}").json() + data = dict(search=name_contains, show_published=False) + index_response = self._get("histories", data=data).json() assert len(index_response) == 3 name_contains = "history that match query" - query = f"?search={name_contains}" - index_response = self._get(f"histories{query}").json() + data = dict(search=name_contains, show_published=False) + index_response = self._get("histories", data=data).json() assert len(index_response) == 3 name_contains = "ANOTHER" - query = f"?search={name_contains}" - index_response = self._get(f"histories{query}").json() + data = dict(search=name_contains, show_published=False) + index_response = self._get("histories", data=data).json() assert len(index_response) == 0 - name_contains = "test" - query = f"?search={name_contains}" - index_response = self._get(f"histories{query}").json() - assert len(index_response) == 3 - data = dict(search="is:deleted", show_published=False) index_response = self._get("histories", data=data).json() assert len(index_response) == 1 self._update(history_0, {"published": True}) - data = dict(search="is:published") + data = dict(search=f"query_{unique_id} is:published") index_response = self._get("histories", data=data).json() assert len(index_response) == 1