diff --git a/atst/domain/permission_sets.py b/atst/domain/permission_sets.py index e78a7cab..1308ec5f 100644 --- a/atst/domain/permission_sets.py +++ b/atst/domain/permission_sets.py @@ -32,12 +32,17 @@ class PermissionSets(object): @classmethod def get_many(cls, perms_set_names): - return ( + permission_sets = ( db.session.query(PermissionSet) .filter(PermissionSet.name.in_(perms_set_names)) .all() ) + if len(permission_sets) != len(perms_set_names): + raise NotFoundError("permission_set") + + return permission_sets + ATAT_ROLES = [ { diff --git a/tests/domain/test_permission_sets.py b/tests/domain/test_permission_sets.py index df19c24d..993cdad4 100644 --- a/tests/domain/test_permission_sets.py +++ b/tests/domain/test_permission_sets.py @@ -30,3 +30,8 @@ def test_get_many(): assert first_or_none( 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"]) diff --git a/tests/domain/test_users.py b/tests/domain/test_users.py index b7030b9c..c83cbd1e 100644 --- a/tests/domain/test_users.py +++ b/tests/domain/test_users.py @@ -20,10 +20,9 @@ def test_create_user_with_existing_email(): Users.create(DOD_ID, email="thisusersemail@usersRus.com") -@pytest.mark.skip(reason="no more roles") -def test_create_user_with_nonexistent_role(): +def test_create_user_with_nonexistent_permission_set(): with pytest.raises(NotFoundError): - Users.create(DOD_ID, "nonexistent") + Users.create(DOD_ID, permission_sets=["nonexistent"]) def test_get_or_create_nonexistent_user():