def test_get_project_dto_for_mapping_raises_error_if_project_not_published(
            self, mock_project):
        # Arrange
        test_project = Project()
        test_project.status = ProjectStatus.DRAFT.value
        mock_project.return_value = test_project

        # Act / Assert
        with self.assertRaises(ProjectServiceError):
            ProjectService.get_project_dto_for_mapper(123, 'en')
Example #2
0
    def test_user_cant_map_if_project_not_published(self, mock_project):
        # Arrange
        stub_project = Project()
        stub_project.status = ProjectStatus.DRAFT.value
        mock_project.return_value = stub_project

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

        # Assert
        self.assertFalse(allowed)
        self.assertEqual(reason, MappingNotAllowed.PROJECT_NOT_PUBLISHED)
    def test_user_not_permitted_to_map_if_user_has_not_accepted_license(
            self, mock_project, mock_user_tasks, mock_user_service):
        # Arrange
        stub_project = Project()
        stub_project.license_id = 11

        mock_project.return_value = stub_project
        mock_user_tasks.return_value = []
        mock_user_service.return_value = False

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

        # Assert
        self.assertFalse(allowed)
Example #4
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 = []

        #Act / Assert
        with self.assertRaises(NotFound):
            ProjectService.get_task_for_logged_in_user(1, 1)
Example #5
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 = [1]

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

        # Assert
        self.assertFalse(allowed)
    def test_user_not_permitted_to_map_if_user_is_blocked(
            self, mock_project, mock_user_blocked):

        # Arrange
        mock_project.return_value = Project()
        mock_user_blocked.return_value = True

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

        # Assert
        self.assertFalse(allowed)
        self.assertEqual(reason, MappingNotAllowed.USER_NOT_ON_ALLOWED_LIST)