Exemple #1
0
    def test_user_cant_map_if_project_not_published(
        self, mock_project, mock_user_blocked, mock_user_pm_status
    ):
        # Arrange
        stub_project = Project()
        stub_project.status = ProjectStatus.DRAFT.value
        mock_project.return_value = stub_project

        mock_user_pm_status.return_value = False
        mock_user_blocked.return_value = False

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

        # Assert
        self.assertFalse(allowed)
        self.assertEqual(reason, MappingNotAllowed.PROJECT_NOT_PUBLISHED)
Exemple #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)
Exemple #3
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)
    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)
    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)