コード例 #1
0
ファイル: test_application_roles.py プロジェクト: robgil/atst
def test_get():
    user = UserFactory.create()
    application = ApplicationFactory.create()
    app_role = ApplicationRoleFactory.create(user=user,
                                             application=application)

    assert ApplicationRoles.get(user.id, application.id)
    assert app_role.application == application
    assert app_role.user == user
コード例 #2
0
ファイル: test_settings.py プロジェクト: jimilinuxguy/atst
def test_get_members_data(app, client, user_session):
    user = UserFactory.create()
    application = ApplicationFactory.create(environments=[{
        "name":
        "testing",
        "members": [{
            "user": user,
            "role_name": CSPRole.BASIC_ACCESS.value
        }],
    }])
    environment = application.environments[0]
    app_role = ApplicationRoles.get(user_id=user.id,
                                    application_id=application.id)
    env_role = EnvironmentRoles.get(application_role_id=app_role.id,
                                    environment_id=environment.id)

    user_session(application.portfolio.owner)

    with captured_templates(app) as templates:
        response = app.test_client().get(
            url_for("applications.settings", application_id=application.id))

        assert response.status_code == 200
        _, context = templates[-1]

        member = context["members"][0]
        assert member["role_id"] == app_role.id
        assert member["user_name"] == user.full_name
        assert member["permission_sets"] == {
            "perms_team_mgmt": False,
            "perms_env_mgmt": False,
            "perms_del_env": False,
        }
        assert member["environment_roles"] == [{
            "environment_id":
            str(environment.id),
            "environment_name":
            environment.name,
            "role":
            env_role.role,
        }]
        assert member["role_status"]
        assert isinstance(member["form"], UpdateMemberForm)
コード例 #3
0
ファイル: test_application_roles.py プロジェクト: robgil/atst
def test_get_handles_invalid_id():
    user = UserFactory.create()
    application = ApplicationFactory.create()

    with pytest.raises(NotFoundError):
        ApplicationRoles.get(user.id, application.id)