Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test purging user without prior deletion #488

Merged
merged 6 commits into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -55,7 +58,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 @@ -104,6 +107,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