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
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
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
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
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
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
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
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
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
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
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
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