예제 #1
0
    def get_locked_tasks_for_user(user_id: int):
        """ Gets tasks on project owned by specified user id"""
        tasks = Task.query.filter_by(locked_by=user_id)
        tasks_dto = LockedTasksForUser()
        for task in tasks:
            tasks_dto.locked_tasks.append(task.id)
            tasks_dto.project = task.project_id
            tasks_dto.task_status = TaskStatus(task.task_status).name

        return tasks_dto
예제 #2
0
    def test_user_not_permitted_to_map_if_already_locked_tasks(
        self, mock_project, mock_user_tasks
    ):
        # Arrange
        mock_project.return_value = Project()
        mock_user_tasks.return_value = LockedTasksForUser()

        # Act / Assert
        self.assertFalse(ProjectService.get_task_for_logged_in_user(1).locked_tasks)
    def test_user_not_permitted_to_map_if_already_locked_tasks(
            self, mock_project, mock_user_tasks):
        # Arrange
        mock_project.return_value = Project()
        mock_user_tasks.return_value = LockedTasksForUser()
        mock_user_tasks.return_value.lockedTasks = [1]

        # Act
        allowed, reason = ProjectService.is_user_permitted_to_map(1, 1)

        # Assert
        self.assertFalse(allowed)
예제 #4
0
    def test_user_not_permitted_to_map_if_user_has_not_accepted_license(
        self, mock_project, mock_user_tasks, mock_user_blocked, mock_user_service
    ):
        # Arrange
        stub_project = Project()
        stub_project.status = ProjectStatus.PUBLISHED.value
        stub_project.license_id = 11

        mock_project.return_value = stub_project
        mock_user_tasks.return_value = LockedTasksForUser()
        mock_user_tasks.return_value.locked_tasks = []
        mock_user_service.return_value = False
        mock_user_blocked.return_value = False

        # Act
        allowed, reason = ProjectService.is_user_permitted_to_map(1, 1)

        # Assert
        self.assertFalse(allowed)