Esempio n. 1
0
def test_event_details():
    owner = UserFactory.create()
    user = UserFactory.create()

    portfolio = PortfolioFactory.create(owner=owner)
    portfolio_role = PortfolioRoles.add(user, portfolio.id)

    assert portfolio_role.event_details["updated_user_name"] == user.displayname
    assert portfolio_role.event_details["updated_user_id"] == str(user.id)
Esempio n. 2
0
def test_has_no_portfolio_role_history(session):
    owner = UserFactory.create()
    user = UserFactory.create()

    portfolio = PortfolioFactory.create(owner=owner)
    portfolio_role = PortfolioRoles.add(user, portfolio.id)
    create_event = (session.query(AuditEvent).filter(
        AuditEvent.resource_id == portfolio_role.id,
        AuditEvent.action == "create").one())

    assert not create_event.changed_state
Esempio n. 3
0
def test_make_ppoc():
    portfolio = PortfolioFactory.create()
    original_owner = portfolio.owner
    new_owner = UserFactory.create()

    new_owner_role = PortfolioRoles.add(user=new_owner,
                                        portfolio_id=portfolio.id)

    PortfolioRoles.make_ppoc(portfolio_role=new_owner_role)

    assert portfolio.owner is new_owner
    assert Permissions.EDIT_PORTFOLIO_POC in new_owner_role.permissions
    assert (Permissions.EDIT_PORTFOLIO_POC
            not in PortfolioRoles.get(portfolio_id=portfolio.id,
                                      user_id=original_owner.id).permissions)
Esempio n. 4
0
def test_add_portfolio_role_with_permission_sets():
    portfolio = PortfolioFactory.create()
    new_user = UserFactory.create()
    permission_sets = [PermissionSets.EDIT_PORTFOLIO_APPLICATION_MANAGEMENT]
    port_role = PortfolioRoles.add(new_user,
                                   portfolio.id,
                                   permission_sets=permission_sets)
    assert len(port_role.permission_sets) == 6
    expected_names = [
        PermissionSets.EDIT_PORTFOLIO_APPLICATION_MANAGEMENT,
        PermissionSets.VIEW_PORTFOLIO_APPLICATION_MANAGEMENT,
        PermissionSets.VIEW_PORTFOLIO_FUNDING,
        PermissionSets.VIEW_PORTFOLIO_REPORTS,
        PermissionSets.VIEW_PORTFOLIO_ADMIN,
        PermissionSets.VIEW_PORTFOLIO,
    ]
    actual_names = [prms.name for prms in port_role.permission_sets]
    assert expected_names == expected_names
Esempio n. 5
0
 def add_member(cls, portfolio, member, permission_sets=None):
     portfolio_role = PortfolioRoles.add(member, portfolio.id,
                                         permission_sets)
     return portfolio_role