throw error for missing permission_sets in PermissionSets.get_many
This commit is contained in:
parent
366ada5a90
commit
7c5e931c67
@ -32,12 +32,17 @@ class PermissionSets(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_many(cls, perms_set_names):
|
def get_many(cls, perms_set_names):
|
||||||
return (
|
permission_sets = (
|
||||||
db.session.query(PermissionSet)
|
db.session.query(PermissionSet)
|
||||||
.filter(PermissionSet.name.in_(perms_set_names))
|
.filter(PermissionSet.name.in_(perms_set_names))
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if len(permission_sets) != len(perms_set_names):
|
||||||
|
raise NotFoundError("permission_set")
|
||||||
|
|
||||||
|
return permission_sets
|
||||||
|
|
||||||
|
|
||||||
ATAT_ROLES = [
|
ATAT_ROLES = [
|
||||||
{
|
{
|
||||||
|
@ -30,3 +30,8 @@ def test_get_many():
|
|||||||
assert first_or_none(
|
assert first_or_none(
|
||||||
lambda p: p.name == PermissionSets.EDIT_PORTFOLIO_FUNDING, perms_sets
|
lambda p: p.name == PermissionSets.EDIT_PORTFOLIO_FUNDING, perms_sets
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_many_nonexistent():
|
||||||
|
with pytest.raises(NotFoundError):
|
||||||
|
PermissionSets.get_many(["nonexistent", "not real"])
|
||||||
|
@ -20,10 +20,9 @@ def test_create_user_with_existing_email():
|
|||||||
Users.create(DOD_ID, email="thisusersemail@usersRus.com")
|
Users.create(DOD_ID, email="thisusersemail@usersRus.com")
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason="no more roles")
|
def test_create_user_with_nonexistent_permission_set():
|
||||||
def test_create_user_with_nonexistent_role():
|
|
||||||
with pytest.raises(NotFoundError):
|
with pytest.raises(NotFoundError):
|
||||||
Users.create(DOD_ID, "nonexistent")
|
Users.create(DOD_ID, permission_sets=["nonexistent"])
|
||||||
|
|
||||||
|
|
||||||
def test_get_or_create_nonexistent_user():
|
def test_get_or_create_nonexistent_user():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user