示例#1
0
def test_remove_user_from_observable_project(observable_projects_fixture):
    project = observable_projects_fixture.project

    ProjectsService.addUserToProject(project.id, "newUser")
    assert len(project.users) == 2
    ProjectsService.removeUserFromProject(project.id, "newUser")
    assert len(project.users) == 1
示例#2
0
def test_remove_missing_user_failure(projects_fixture):
    ProjectsService.addUserToProject(projects_fixture.id, "newUser")
    assert len(projects_fixture.users) == 2
    with pytest.raises(ApiException):
        ProjectsService.removeUserFromProject(projects_fixture.id,
                                              "someOtherUser")
    assert len(projects_fixture.users) == 2
示例#3
0
 def post(self, projectId: int):
     payload = request.json
     username = payload["username"]
     logger.info("Add user:{} to project:{} for user:{}".format(
         username,
         projectId,
         request.current_user.username))
     ProjectsService.addUserToProject(projectId, username)
     return "ok"
示例#4
0
def test_remove_last_user_with_jwt_from_observable_project_failure(
        observable_projects_fixture):
    project = observable_projects_fixture.project

    ProjectsService.addUserToProject(project.id, "newUser")
    assert len(project.users) == 2
    with pytest.raises(ApiException):
        ProjectsService.removeUserFromProject(project.id,
                                              project.users[0].username)
    assert len(project.users) == 2
示例#5
0
def test_add_new_user_to_project(userdata):
    user = UserService.getUser("test1", "test")
    data = {
        'project': {
            'name': 'new project',
            'description': 'test'
        },
    }
    proj = ProjectsService.create(data, user)
    ProjectsService.addUserToProject(proj.id, "newUser")
    proj = ProjectsService.get(project_id=proj.id)
    assert len(proj.users) == 2
示例#6
0
def test_remove_user(projects_fixture):
    ProjectsService.addUserToProject(projects_fixture.id, "newUser")
    assert len(projects_fixture.users) == 2
    ProjectsService.removeUserFromProject(projects_fixture.id, "newUser")
    assert len(projects_fixture.users) == 1