diff --git a/atst/routes/portfolios/index.py b/atst/routes/portfolios/index.py index 767f56aa..ecb1f361 100644 --- a/atst/routes/portfolios/index.py +++ b/atst/routes/portfolios/index.py @@ -16,6 +16,7 @@ from atst.models.permissions import Permissions from atst.domain.permission_sets import PermissionSets from atst.domain.authz.decorator import user_can_access_decorator as user_can from atst.utils.flash import formatted_flash as flash +from atst.domain.exceptions import UnauthorizedError @portfolios_bp.route("/portfolios") @@ -184,7 +185,7 @@ def portfolio_reports(portfolio_id): def remove_member(portfolio_id, member_id): if member_id == str(g.current_user.id): raise UnauthorizedError( - user=user, message="you cant remove yourself from the portfolio" + user=g.current_user, action="you cant remove yourself from the portfolio" ) portfolio = Portfolios.get(g.current_user, portfolio_id) diff --git a/tests/routes/portfolios/test_portfolios_index.py b/tests/routes/portfolios/test_portfolios_index.py index d4fdeaba..29672f9c 100644 --- a/tests/routes/portfolios/test_portfolios_index.py +++ b/tests/routes/portfolios/test_portfolios_index.py @@ -126,7 +126,7 @@ def test_remove_portfolio_member_self(client, user_session): follow_redirects=False, ) - assert response.status_code == 500 + assert response.status_code == 404 assert ( PortfolioRoles.get(portfolio_id=portfolio.id, user_id=portfolio.owner.id).status == PortfolioRoleStatus.ACTIVE