Skip to content

Commit

Permalink
Move test fixture to conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Oct 25, 2024
1 parent a8a861c commit 0063dd5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 18 additions & 0 deletions test/unit/data/model/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,24 @@ def f(**kwd):
return f


@pytest.fixture
def make_user_and_role(session, make_user, make_role, make_user_role_association):
"""
Each user created in Galaxy is assumed to have a private role, such that role.type == Role.types.PRIVATE.
Since we are testing user/group/role associations here, to ensure the correct state of the test database,
we need to ensure that a user is never created without a corresponding private role.
Therefore, we use this fixture instead of make_user (which only creates a user).
"""

def f(**kwd):
user = make_user(**kwd)
private_role = make_role(type=m.Role.types.PRIVATE)
make_user_role_association(user, private_role)
return user, private_role

return f


@pytest.fixture
def make_user_item_rating_association(session):
def f(assoc_class, user, item, rating):
Expand Down
18 changes: 0 additions & 18 deletions test/unit/data/model/db/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,6 @@
from . import have_same_elements


@pytest.fixture
def make_user_and_role(session, make_user, make_role, make_user_role_association):
"""
Each user created in Galaxy is assumed to have a private role, such that role.type == Role.types.PRIVATE.
Since we are testing user/group/role associations here, to ensure the correct state of the test database,
we need to ensure that a user is never created without a corresponding private role.
Therefore, we use this fixture instead of make_user (which only creates a user).
"""

def f(**kwd):
user = make_user()
private_role = make_role(type=Role.types.PRIVATE)
make_user_role_association(user, private_role)
return user, private_role

return f


def test_private_user_role_assoc_not_affected_by_setting_user_roles(session, make_user_and_role):
# Create user with a private role
user, private_role = make_user_and_role()
Expand Down

0 comments on commit 0063dd5

Please sign in to comment.