Exemple #1
0
    def test_lock_tasks_for_validation_raises_error_if_task_not_found(
            self, mock_task):
        # Arrange
        mock_task.return_value = None

        lock_dto = LockForValidationDTO()
        lock_dto.project_id = 1
        lock_dto.task_ids = [1, 2]

        # Act / Assert
        with self.assertRaises(NotFound):
            ValidatorService.lock_tasks_for_validation(lock_dto)
Exemple #2
0
    def test_lock_tasks_for_validation_raises_error_if_task_not_mapped(
            self, mock_task):
        # Arrange
        task_stub = Task()
        task_stub.task_status = TaskStatus.READY.value
        mock_task.return_value = task_stub

        lock_dto = LockForValidationDTO()
        lock_dto.project_id = 1
        lock_dto.task_ids = [1, 2]

        # Act / Assert
        with self.assertRaises(ValidatorServiceError):
            ValidatorService.lock_tasks_for_validation(lock_dto)
Exemple #3
0
    def test_lock_tasks_raises_error_if_project_validator_only_and_user_not_validator(
            self, mock_project, mock_task, mock_user):
        # Arrange
        task_stub = Task()
        task_stub.task_status = TaskStatus.MAPPED.value
        mock_task.return_value = task_stub
        mock_project.return_value = False, ValidatingNotAllowed.USER_NOT_VALIDATOR
        mock_user.return_value = True

        lock_dto = LockForValidationDTO()
        lock_dto.project_id = 1
        lock_dto.task_ids = [1, 2]
        lock_dto.user_id = 1234

        with self.assertRaises(ValidatorServiceError):
            ValidatorService.lock_tasks_for_validation(lock_dto)
Exemple #4
0
    def test_lock_tasks_raises_error_if_user_has_not_accepted_license(
            self, mock_project, mock_task, mock_user):
        # Arrange
        task_stub = Task()
        task_stub.task_status = TaskStatus.MAPPED.value
        mock_task.return_value = task_stub

        mock_project.return_value = (
            False,
            ValidatingNotAllowed.USER_NOT_ACCEPTED_LICENSE,
        )
        mock_user.return_value = True

        lock_dto = LockForValidationDTO()
        lock_dto.project_id = 1
        lock_dto.task_ids = [1, 2]
        lock_dto.user_id = 123
        lock_dto.mapped_by = 1234

        with self.assertRaises(UserLicenseError):
            ValidatorService.lock_tasks_for_validation(lock_dto)