Skip to content

Commit

Permalink
Fix test_index_advanced_filter API test re-running
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nsoranzo committed Feb 26, 2024
1 parent c00a47a commit 24063e5
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions lib/galaxy_test/api/test_histories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 24063e5

Please sign in to comment.