Skip to content

Commit

Permalink
Test purging user without prior deletion (galaxyproject#488)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicola Soranzo <[email protected]>
  • Loading branch information
bernt-matthias and nsoranzo committed Jul 9, 2024
1 parent 5f1dea0 commit 406b32c
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions bioblend/_tests/TestGalaxyUsers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import bioblend.galaxy
import pytest

from bioblend import ConnectionError
from bioblend.galaxy import GalaxyInstance
from . import (
GalaxyTestBase,
test_util,
Expand Down Expand Up @@ -56,7 +59,7 @@ def test_create_local_user(self):
assert new_user["username"] == new_username
assert new_user["email"] == new_user_email
# test a BioBlend GalaxyInstance can be created using username+password
user_gi = bioblend.galaxy.GalaxyInstance(url=self.gi.base_url, email=new_user_email, password=password)
user_gi = GalaxyInstance(url=self.gi.base_url, email=new_user_email, password=password)
assert user_gi.users.get_current_user()["email"] == new_user_email
# test deletion and purging
if self.gi.config.get_config()["allow_user_deletion"]:
Expand Down Expand Up @@ -105,6 +108,24 @@ def test_update_user(self):
assert purged_user["deleted"]
assert purged_user["purged"]

@test_util.skip_unless_galaxy("release_19.09") # for user purging
def test_direct_purge(self):
"""
Test purging without prior deletion
"""
# WARNING: only admins can create users!
if self.gi.config.get_config()["use_remote_user"]:
self.skipTest("This Galaxy instance is not configured to use local users")
if not self.gi.config.get_config()["allow_user_deletion"]:
self.skipTest("This Galaxy instance is not configured to allow user deletion")
new_username = test_util.random_string()
new_user = self.gi.users.create_local_user(
new_username, f"{new_username}@example.org", test_util.random_string(20)
)
# Purging a user fails if it's not deleted beforehand
with pytest.raises(ConnectionError):
self.gi.users.delete_user(new_user["id"], purge=True)

def test_get_user_apikey(self):
# Test getting the API key of the current user, which surely has one
user_id = self.gi.users.get_current_user()["id"]
Expand Down

0 comments on commit 406b32c

Please sign in to comment.