Example #1
0
    def test_illegal_get_next_task_status(self):
        task = self.tasks['awaiting_processing']
        illegal_statuses = [
            Task.Status.AWAITING_PROCESSING,
            Task.Status.PENDING_REVIEW,
            Task.Status.COMPLETE
        ]

        iteration_statuses = [
            Iteration.Status.REQUESTED_REVIEW,
            Iteration.Status.PROVIDED_REVIEW
        ]

        for status in illegal_statuses:
            for iteration_status in iteration_statuses:
                with self.assertRaises(IllegalTaskSubmission):
                    task.status = status
                    get_next_task_status(task, iteration_status)

        # Entry level-related statuses cannot be rejected
        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.PROCESSING
            get_next_task_status(task, Iteration.Status.PROVIDED_REVIEW)

        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.POST_REVIEW_PROCESSING
            get_next_task_status(task, Iteration.Status.PROVIDED_REVIEW)
Example #2
0
    def test_illegal_get_next_task_status(self):
        task = self.tasks['awaiting_processing']
        illegal_statuses = [
            Task.Status.AWAITING_PROCESSING, Task.Status.PENDING_REVIEW,
            Task.Status.COMPLETE
        ]

        iteration_statuses = [
            Iteration.Status.REQUESTED_REVIEW, Iteration.Status.PROVIDED_REVIEW
        ]

        for status in illegal_statuses:
            for iteration_status in iteration_statuses:
                with self.assertRaises(IllegalTaskSubmission):
                    task.status = status
                    get_next_task_status(task, iteration_status)

        # Entry level-related statuses cannot be rejected
        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.PROCESSING
            get_next_task_status(task, Iteration.Status.PROVIDED_REVIEW)

        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.POST_REVIEW_PROCESSING
            get_next_task_status(task, Iteration.Status.PROVIDED_REVIEW)
Example #3
0
 def test_sampled_get_next_task_status(self):
     task = self.tasks['awaiting_processing']
     step = task.step
     step.review_policy = {'policy': 'sampled_review',
                           'rate': 0.5,
                           'max_reviews': 1}
     step.save()
     task.status = Task.Status.PROCESSING
     complete_count = 0
     for i in range(0, 1000):
         next_status = get_next_task_status(
             task, Iteration.Status.REQUESTED_REVIEW)
         complete_count += next_status == Task.Status.COMPLETE
     self.assertTrue(complete_count > 400)
     self.assertTrue(complete_count < 600)
Example #4
0
 def test_sampled_get_next_task_status(self):
     task = self.tasks['processing_task']
     workflow = get_workflow_by_slug(task.project.workflow_slug)
     step = workflow.get_step(task.step_slug)
     step.review_policy = {'policy': 'sampled_review',
                           'rate': 0.5,
                           'max_reviews': 1}
     task.status = Task.Status.PROCESSING
     complete_count = 0
     for i in range(0, 1000):
         next_status = get_next_task_status(
             task, TaskAssignment.SnapshotType.SUBMIT)
         complete_count += next_status == Task.Status.COMPLETE
     self.assertTrue(complete_count > 400)
     self.assertTrue(complete_count < 600)
Example #5
0
 def test_sampled_get_next_task_status(self):
     task = self.tasks['awaiting_processing']
     step = task.step
     step.review_policy = {'policy': 'sampled_review',
                           'rate': 0.5,
                           'max_reviews': 1}
     step.save()
     task.status = Task.Status.PROCESSING
     complete_count = 0
     for i in range(0, 1000):
         next_status = get_next_task_status(
             task, Iteration.Status.REQUESTED_REVIEW)
         complete_count += next_status == Task.Status.COMPLETE
     self.assertTrue(complete_count > 400)
     self.assertTrue(complete_count < 600)
 def test_sampled_get_next_task_status(self):
     task = self.tasks['awaiting_processing']
     step = task.step
     step.review_policy = {'policy': 'sampled_review',
                           'rate': 0.5,
                           'max_reviews': 1}
     step.save()
     task.status = Task.Status.PROCESSING
     complete_count = 0
     for i in range(0, 1000):
         next_status = get_next_task_status(
             task, TaskAssignment.SnapshotType.SUBMIT)
         complete_count += next_status == Task.Status.COMPLETE
     self.assertTrue(complete_count > 400)
     self.assertTrue(complete_count < 600)
 def test_sampled_get_next_task_status(self):
     task = self.tasks['awaiting_processing']
     step = task.step
     step.review_policy = {
         'policy': 'sampled_review',
         'rate': 0.5,
         'max_reviews': 1
     }
     step.save()
     task.status = Task.Status.PROCESSING
     complete_count = 0
     for i in range(0, 1000):
         next_status = get_next_task_status(
             task, TaskAssignment.SnapshotType.SUBMIT)
         complete_count += next_status == Task.Status.COMPLETE
     self.assertTrue(complete_count > 400)
     self.assertTrue(complete_count < 600)
Example #8
0
    def test_legal_get_next_task_status(self):
        task = self.tasks['awaiting_processing']
        step = task.step

        task.status = Task.Status.PROCESSING
        step.review_policy = {}
        step.save()
        with self.assertRaises(ReviewPolicyError):
            get_next_task_status(task, Iteration.Status.REQUESTED_REVIEW)

        step.review_policy = {
            'policy': 'sampled_review',
            'rate': 1,
            'max_reviews': 1
        }
        step.save()
        self.assertEquals(
            get_next_task_status(task, Iteration.Status.REQUESTED_REVIEW),
            Task.Status.PENDING_REVIEW)

        step.review_policy = {
            'policy': 'sampled_review',
            'rate': 0,
            'max_reviews': 1
        }
        step.save()
        self.assertEquals(
            get_next_task_status(task, Iteration.Status.REQUESTED_REVIEW),
            Task.Status.COMPLETE)

        task.status = Task.Status.POST_REVIEW_PROCESSING
        self.assertEquals(
            get_next_task_status(task, Iteration.Status.REQUESTED_REVIEW),
            Task.Status.REVIEWING)

        task = self.tasks['review_task']
        task.status = Task.Status.REVIEWING

        step.review_policy = {
            'policy': 'sampled_review',
            'rate': 1,
            'max_reviews': 0
        }
        step.save()
        self.assertEquals(
            get_next_task_status(task, Iteration.Status.REQUESTED_REVIEW),
            Task.Status.COMPLETE)

        step.review_policy = {
            'policy': 'sampled_review',
            'rate': 1,
            'max_reviews': 2
        }
        step.save()
        self.assertEquals(
            get_next_task_status(task, Iteration.Status.REQUESTED_REVIEW),
            Task.Status.PENDING_REVIEW)

        # after max reviews done a task goes to state complete
        TaskAssignment.objects.create(worker=self.workers[1],
                                      task=task,
                                      status=TaskAssignment.Status.SUBMITTED,
                                      assignment_counter=1,
                                      in_progress_task_data={})
        task.save()
        step.review_policy = {
            'policy': 'sampled_review',
            'rate': 1,
            'max_reviews': 1
        }
        step.save()
        self.assertEquals(
            get_next_task_status(task, Iteration.Status.REQUESTED_REVIEW),
            Task.Status.COMPLETE)
Example #9
0
    def test_legal_get_next_task_status(self):
        task = self.tasks['awaiting_processing']
        step = task.step

        task.status = Task.Status.PROCESSING
        step.review_policy = {}
        step.save()
        with self.assertRaises(ReviewPolicyError):
            get_next_task_status(task,
                                 Iteration.Status.REQUESTED_REVIEW)

        step.review_policy = {'policy': 'sampled_review',
                              'rate': 1,
                              'max_reviews': 1}
        step.save()
        self.assertEquals(
            get_next_task_status(task,
                                 Iteration.Status.REQUESTED_REVIEW),
            Task.Status.PENDING_REVIEW)

        step.review_policy = {'policy': 'sampled_review',
                              'rate': 0,
                              'max_reviews': 1}
        step.save()
        self.assertEquals(
            get_next_task_status(task,
                                 Iteration.Status.REQUESTED_REVIEW),
            Task.Status.COMPLETE)

        task.status = Task.Status.POST_REVIEW_PROCESSING
        self.assertEquals(
            get_next_task_status(task,
                                 Iteration.Status.REQUESTED_REVIEW),
            Task.Status.REVIEWING)

        task = self.tasks['review_task']
        task.status = Task.Status.REVIEWING

        step.review_policy = {'policy': 'sampled_review',
                              'rate': 1,
                              'max_reviews': 0}
        step.save()
        self.assertEquals(
            get_next_task_status(task,
                                 Iteration.Status.REQUESTED_REVIEW),
            Task.Status.COMPLETE)

        step.review_policy = {'policy': 'sampled_review',
                              'rate': 1,
                              'max_reviews': 2}
        step.save()
        self.assertEquals(
            get_next_task_status(task,
                                 Iteration.Status.REQUESTED_REVIEW),
            Task.Status.PENDING_REVIEW)

        # after max reviews done a task goes to state complete
        TaskAssignment.objects.create(
            worker=self.workers[1],
            task=task,
            status=TaskAssignment.Status.SUBMITTED,
            assignment_counter=1,
            in_progress_task_data={})
        task.save()
        step.review_policy = {'policy': 'sampled_review',
                              'rate': 1,
                              'max_reviews': 1}
        step.save()
        self.assertEquals(
            get_next_task_status(task,
                                 Iteration.Status.REQUESTED_REVIEW),
            Task.Status.COMPLETE)
Example #10
0
    def test_legal_get_next_task_status(self):
        task = self.tasks['processing_task']
        workflow = get_workflow_by_slug(task.project.workflow_slug)
        step = workflow.get_step(task.step_slug)
        step.review_policy = {}

        task.status = Task.Status.PROCESSING
        with self.assertRaises(ReviewPolicyError):
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.SUBMIT)

        step.review_policy = {'policy': 'sampled_review',
                              'rate': 1,
                              'max_reviews': 1}
        self.assertEquals(
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.SUBMIT),
            Task.Status.PENDING_REVIEW)

        step.review_policy = {'policy': 'sampled_review',
                              'rate': 0,
                              'max_reviews': 1}
        self.assertEquals(
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.SUBMIT),
            Task.Status.COMPLETE)

        task.status = Task.Status.POST_REVIEW_PROCESSING
        self.assertEquals(
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.SUBMIT),
            Task.Status.REVIEWING)

        task = self.tasks['review_task']
        task.status = Task.Status.REVIEWING

        step.review_policy = {'policy': 'sampled_review',
                              'rate': 1,
                              'max_reviews': 0}
        self.assertEquals(
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.ACCEPT),
            Task.Status.COMPLETE)

        step.review_policy = {'policy': 'sampled_review',
                              'rate': 1,
                              'max_reviews': 2}
        self.assertEquals(
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.ACCEPT),
            Task.Status.PENDING_REVIEW)

        # after max reviews done a task goes to state complete
        TaskAssignment.objects.create(worker=self.workers[1],
                                      task=task,
                                      status=TaskAssignment.Status.SUBMITTED,
                                      assignment_counter=1,
                                      in_progress_task_data={},
                                      snapshots=empty_snapshots())
        task.save()
        step.review_policy = {'policy': 'sampled_review',
                              'rate': 1,
                              'max_reviews': 1}
        self.assertEquals(
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.ACCEPT),
            Task.Status.COMPLETE)
Example #11
0
    def test_illegal_get_next_task_status(self):
        task = self.tasks['processing_task']
        illegal_statuses = [Task.Status.AWAITING_PROCESSING,
                            Task.Status.PENDING_REVIEW,
                            Task.Status.COMPLETE]

        snapshot_types = [TaskAssignment.SnapshotType.SUBMIT,
                          TaskAssignment.SnapshotType.ACCEPT,
                          TaskAssignment.SnapshotType.REJECT]

        for status in illegal_statuses:
            for snapshot_type in snapshot_types:
                with self.assertRaises(IllegalTaskSubmission):
                    task.status = Task.Status.REVIEWING
                    get_next_task_status(task,
                                         TaskAssignment.SnapshotType.SUBMIT)

        # Entry level-related statuses cannot be accepted or rejected
        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.PROCESSING
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.ACCEPT)

        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.PROCESSING
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.REJECT)

        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.PROCESSING
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.ACCEPT)

        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.POST_REVIEW_PROCESSING
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.REJECT)

        # Reviewer related statuses cannot be submitted
        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.REVIEWING
            get_next_task_status(task,
                                 TaskAssignment.SnapshotType.SUBMIT)
Example #12
0
    def test_illegal_get_next_task_status(self):
        task = self.tasks['awaiting_processing']
        illegal_statuses = [
            Task.Status.AWAITING_PROCESSING, Task.Status.PENDING_REVIEW,
            Task.Status.COMPLETE
        ]

        snapshot_types = [
            TaskAssignment.SnapshotType.SUBMIT,
            TaskAssignment.SnapshotType.ACCEPT,
            TaskAssignment.SnapshotType.REJECT
        ]

        for status in illegal_statuses:
            for snapshot_type in snapshot_types:
                with self.assertRaises(IllegalTaskSubmission):
                    task.status = Task.Status.REVIEWING
                    get_next_task_status(task,
                                         TaskAssignment.SnapshotType.SUBMIT)

        # Entry level-related statuses cannot be accepted or rejected
        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.PROCESSING
            get_next_task_status(task, TaskAssignment.SnapshotType.ACCEPT)

        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.PROCESSING
            get_next_task_status(task, TaskAssignment.SnapshotType.REJECT)

        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.PROCESSING
            get_next_task_status(task, TaskAssignment.SnapshotType.ACCEPT)

        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.POST_REVIEW_PROCESSING
            get_next_task_status(task, TaskAssignment.SnapshotType.REJECT)

        # Reviewer related statuses cannot be submitted
        with self.assertRaises(IllegalTaskSubmission):
            task.status = Task.Status.REVIEWING
            get_next_task_status(task, TaskAssignment.SnapshotType.SUBMIT)