From 6b3c3f0eae9a370c50d32405786a7baeefd66ce2 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 15 Mar 2024 12:59:45 +0100 Subject: [PATCH] Add test for /api/users/current creating a history --- lib/galaxy_test/api/test_authenticate.py | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/galaxy_test/api/test_authenticate.py b/lib/galaxy_test/api/test_authenticate.py index 7cd375516a32..d744bea0dd90 100644 --- a/lib/galaxy_test/api/test_authenticate.py +++ b/lib/galaxy_test/api/test_authenticate.py @@ -75,3 +75,28 @@ def test_anon_history_creation(self): cookies=cookie, ) assert second_histories_response.json() + + def test_anon_history_creation_api(self): + # First request: + # We don't create any histories, just return a session cookie + response = get(self.url) + cookie = {"galaxysession": response.cookies["galaxysession"]} + # Check that we don't have any histories (API doesn't auto-create new histories) + histories_response = get( + urljoin( + self.url, + "api/histories", + ) + ) + assert not histories_response.json() + # Second request, we know client follows conventions by including cookies, + # default history is created. + get(urljoin(self.url, "api/users/current"), cookies=cookie).raise_for_status() + histories_response = get( + urljoin( + self.url, + "api/histories", + ), + cookies=cookie, + ) + assert histories_response.json()