Skip to content

Commit

Permalink
Update unit test w/new method name
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Oct 31, 2024
1 parent 6c59904 commit 4be1eaf
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/unit/data/model/db/test_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
get_private_user_role,
get_roles_by_ids,
)
from galaxy.model.security import _get_valid_roles_case1
from galaxy.model.security import _get_valid_roles_exposed
from . import have_same_elements


Expand Down Expand Up @@ -45,7 +45,7 @@ def test_get_roles_by_ids(session, make_role):
have_same_elements(roles2, expected)


def test_get_valid_roles_case1(session, make_user_and_role, make_user, make_role, make_user_role_association):
def test_get_valid_roles_exposed(session, make_user_and_role, make_user, make_role, make_user_role_association):
# Make 3 users with private roles
(
u1,
Expand Down Expand Up @@ -79,63 +79,63 @@ def test_get_valid_roles_case1(session, make_user_and_role, make_user, make_role
is_admin = True

search_query = None
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 7 # all roles returned

search_query = "foo%"
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 2
assert rp1 in roles
assert rp2 in roles

search_query = "foo1%"
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 1
assert roles[0] == rp1

search_query = "sharing%"
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 2
assert rs1 in roles
assert rs2 in roles

search_query = "sharing role for u1%"
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 1
assert roles[0] == rs1

search_query = "admin role%"
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 2
assert ra1 in roles
assert ra2 in roles

search_query = "admin role1%"
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 1
assert roles[0] == ra1

is_admin = False # non admins should see only private roles

search_query = None
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 3

search_query = "foo%"
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 2
assert rp1 in roles
assert rp2 in roles

search_query = "foo1%"
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 1
assert roles[0] == rp1

search_query = "sharing%"
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 0

search_query = "admin role%"
roles = _get_valid_roles_case1(session, search_query, is_admin, limit, page, page_limit)
roles = _get_valid_roles_exposed(session, search_query, is_admin, limit, page, page_limit)
assert len(roles) == 0

0 comments on commit 4be1eaf

Please sign in to comment.