コード例 #1
0
    def test_check_contributing_state_draft_presenter(self):
        """Test check_contributing_state returns 'draft' for a project that has
        no tasks but has a presenter"""
        project = ProjectFactory.create()
        user = UserFactory.create()

        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert 'task_presenter' in project.info
        assert contributing_state == 'draft', contributing_state
コード例 #2
0
    def test_check_contributing_state_ongoing_tasks_not_contributed(self):
        """Test check_contributing_state returns 'can_contribute' for a project
        with ongoing tasks a user has not contributed to"""
        project = ProjectFactory.create()
        task = TaskFactory.create(project=project)
        user = UserFactory.create()

        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert contributing_state == 'can_contribute', contributing_state
コード例 #3
0
    def test_check_contributing_state_ongoing_tasks_contributed(self):
        """Test check_contributing_state returns 'cannot_contribute' for a project
        with ongoing tasks to which the user has already contributed"""
        project = ProjectFactory.create()
        task = TaskFactory.create(project=project, n_answers=3)
        user = UserFactory.create()
        TaskRunFactory.create(task=task, user=user)
        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert contributing_state == 'cannot_contribute', contributing_state
コード例 #4
0
ファイル: test_cache_helpers.py プロジェクト: lsuttle/pybossa
    def test_check_contributing_state_draft_presenter(self):
        """Test check_contributing_state returns 'draft' for a project that has
        no tasks but has a presenter"""
        project = ProjectFactory.create(published=False)
        user = UserFactory.create()

        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert 'task_presenter' in project.info
        assert contributing_state == 'draft', contributing_state
コード例 #5
0
ファイル: test_cache_helpers.py プロジェクト: lsuttle/pybossa
    def test_check_contributing_state_ongoing_tasks_not_contributed(self):
        """Test check_contributing_state returns 'can_contribute' for a project
        with ongoing tasks a user has not contributed to"""
        project = ProjectFactory.create()
        task = TaskFactory.create(project=project)
        user = UserFactory.create()

        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert contributing_state == 'can_contribute', contributing_state
コード例 #6
0
ファイル: test_cache_helpers.py プロジェクト: lsuttle/pybossa
    def test_check_contributing_state_ongoing_tasks_contributed(self):
        """Test check_contributing_state returns 'cannot_contribute' for a project
        with ongoing tasks to which the user has already contributed"""
        project = ProjectFactory.create()
        task = TaskFactory.create(project=project, n_answers=3)
        user = UserFactory.create()
        TaskRunFactory.create(task=task, user=user)
        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert contributing_state == 'cannot_contribute', contributing_state
コード例 #7
0
    def test_check_contributing_state_ongoing_tasks_not_contributed(self):
        """Test check_contributing_state returns 'can_contribute' for an app
        with ongoing tasks a user has not contributed to"""
        app = AppFactory.create()
        task = TaskFactory.create(app=app)
        user = UserFactory.create()

        contributing_state = helpers.check_contributing_state(app_id=app.id,
                                                              user_id=user.id)

        assert contributing_state == 'can_contribute', contributing_state
コード例 #8
0
ファイル: test_cache_helpers.py プロジェクト: lsuttle/pybossa
    def test_check_contributing_state_publish(self):
        """Test check_contributing_state returns 'publish' for a project that is
        not published but is ready to be validated for publication (i.e. has both
        tasks and a task presenter"""
        project = ProjectFactory.create(published=False)
        task = TaskFactory.create(project=project)
        user = UserFactory.create()

        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert contributing_state == 'publish', contributing_state
コード例 #9
0
    def test_check_contributing_state_draft(self):
        """Test check_contributing_state returns 'draft' for a project that has
        ongoing tasks but has no presenter"""
        project = ProjectFactory.create(info={})
        task = TaskFactory.create(project=project)
        user = UserFactory.create()

        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert 'task_presenter' not in project.info
        assert contributing_state == 'draft', contributing_state
コード例 #10
0
    def test_check_contributing_state_publish(self):
        """Test check_contributing_state returns 'publish' for a project that is
        not published but is ready to be validated for publication (i.e. has both
        tasks and a task presenter"""
        project = ProjectFactory.create(published=False)
        task = TaskFactory.create(project=project)
        user = UserFactory.create()

        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert contributing_state == 'publish', contributing_state
コード例 #11
0
    def test_check_contributing_state_draft(self):
        """Test check_contributing_state returns 'draft' for a project that has
        ongoing tasks but has no presenter"""
        project = ProjectFactory.create(published=False, info={})
        task = TaskFactory.create(project=project)
        user = UserFactory.create()

        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert 'task_presenter' not in project.info
        assert contributing_state == 'draft', contributing_state
コード例 #12
0
    def test_check_contributing_state_draft(self):
        """Test check_contributing_state returns 'draft' for a project that has
        ongoing tasks but has no presenter"""
        app = AppFactory.create(info={})
        task = TaskFactory.create(app=app)
        user = UserFactory.create()

        contributing_state = helpers.check_contributing_state(app=app,
                                                              user_id=user.id)

        assert 'task_presenter' not in app.info
        assert contributing_state == 'draft', contributing_state
コード例 #13
0
    def test_check_contributing_state_completed_user_not_contributed(self):
        """Test check_contributing_state returns 'completed' for a project with all
        tasks completed even if the user has not contributed to it"""
        project = ProjectFactory.create()
        task = TaskFactory.create(project=project, n_answers=2)
        TaskRunFactory.create_batch(2, task=task)
        user = UserFactory.create()

        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert task.state == 'completed', task.state
        assert contributing_state == 'completed', contributing_state
コード例 #14
0
    def test_check_contributing_state_completed(self):
        """Test check_contributing_state returns 'completed' for a project with all
        tasks completed and user that has contributed to it"""
        project = ProjectFactory.create()
        task = TaskFactory.create(project=project, n_answers=1)
        user = UserFactory.create()
        TaskRunFactory.create_batch(1, task=task, user=user)

        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert task.state == 'completed', task.state
        assert contributing_state == 'completed', contributing_state
コード例 #15
0
ファイル: test_cache_helpers.py プロジェクト: lsuttle/pybossa
    def test_check_contributing_state_completed_user_not_contributed(self):
        """Test check_contributing_state returns 'completed' for a project with all
        tasks completed even if the user has not contributed to it"""
        project = ProjectFactory.create()
        task = TaskFactory.create(project=project, n_answers=2)
        TaskRunFactory.create_batch(2, task=task)
        user = UserFactory.create()
        update_stats(project.id)
        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert task.state == 'completed', task.state
        assert contributing_state == 'completed', contributing_state
コード例 #16
0
    def test_check_contributing_state_completed(self):
        """Test check_contributing_state returns 'completed' for a project with all
        tasks completed and user that has contributed to it"""
        project = ProjectFactory.create()
        task = TaskFactory.create(project=project, n_answers=1)
        user = UserFactory.create()
        TaskRunFactory.create_batch(1, task=task, user=user)

        contributing_state = helpers.check_contributing_state(project=project,
                                                              user_id=user.id)

        assert task.state == 'completed', task.state
        assert contributing_state == 'completed', contributing_state