Exemple #1
0
 def test_user_is_both_leader_and_approver(self):
     """A single user cannot appear twice in the same distribution list."""
     self.data.update({
         'leader': self.user.id,
         'approver': self.user.id
     })
     form = ContractorDeliverableRevisionForm(self.data, category=self.category)
     self.assertFalse(form.is_valid())
Exemple #2
0
 def test_user_is_both_leader_and_approver(self):
     """A single user cannot appear twice in the same distribution list."""
     self.data.update({
         'leader': self.user.id,
         'approver': self.user.id
     })
     form = ContractorDeliverableRevisionForm(self.data, category=self.category)
     self.assertFalse(form.is_valid())
Exemple #3
0
    def test_removing_reviewers_can_end_reviewers_step(self):
        """Remove all reviewers, and the review goes up to leader step."""
        self.rev.reviewers.add(self.user4)
        self.rev.start_review()

        leader_review = self.rev.get_review(self.user2)
        self.assertEqual(leader_review.status, 'pending')

        # Count Review objects
        qs = Review.objects \
            .filter(document=self.rev.document) \
            .filter(revision=self.rev.revision) \
            .filter(role='reviewer')
        self.assertEqual(qs.count(), 2)

        # Remove one reviewer
        self.data.update({'reviewers': str(self.user.id)})
        form = ContractorDeliverableRevisionForm(
            self.data,
            instance=self.rev,
            category=self.category)
        self.assertTrue(form.is_valid())
        form.save()

        # Assert the reviewers step is still open
        self.rev.refresh_from_db()
        self.assertIsNone(self.rev.reviewers_step_closed)
        self.assertEqual(qs.count(), 1)

        # Remove second reviewer
        self.data.update({'reviewers': ''})
        form = ContractorDeliverableRevisionForm(
            self.data,
            instance=self.rev,
            category=self.category)
        self.assertTrue(form.is_valid())
        form.save()

        # Assert the reviewers step is closed
        self.rev.refresh_from_db()
        self.assertEqual(qs.count(), 0)
        self.assertIsNotNone(self.rev.reviewers_step_closed)

        leader_review.refresh_from_db()
        self.assertEqual(leader_review.status, 'progress')
Exemple #4
0
    def test_removing_reviewers_can_end_reviewers_step(self):
        """Remove all reviewers, and the review goes up to leader step."""
        self.rev.reviewers.add(self.user4)
        self.rev.start_review()

        leader_review = self.rev.get_review(self.user2)
        self.assertEqual(leader_review.status, 'pending')

        # Count Review objects
        qs = Review.objects \
            .filter(document=self.rev.document) \
            .filter(revision=self.rev.revision) \
            .filter(role='reviewer')
        self.assertEqual(qs.count(), 2)

        # Remove one reviewer
        self.data.update({'reviewers': str(self.user.id)})
        form = ContractorDeliverableRevisionForm(
            self.data,
            instance=self.rev,
            category=self.category)
        self.assertTrue(form.is_valid())
        form.save()

        # Assert the reviewers step is still open
        self.rev.refresh_from_db()
        self.assertIsNone(self.rev.reviewers_step_closed)
        self.assertEqual(qs.count(), 1)

        # Remove second reviewer
        self.data.update({'reviewers': ''})
        form = ContractorDeliverableRevisionForm(
            self.data,
            instance=self.rev,
            category=self.category)
        self.assertTrue(form.is_valid())
        form.save()

        # Assert the reviewers step is closed
        self.rev.refresh_from_db()
        self.assertEqual(qs.count(), 0)
        self.assertIsNotNone(self.rev.reviewers_step_closed)

        leader_review.refresh_from_db()
        self.assertEqual(leader_review.status, 'progress')
Exemple #5
0
 def test_reviewers_cannot_be_deleted_after_reviewers_step(self):
     self.rev.start_review()
     self.rev.end_reviewers_step()
     self.data.update({'reviewers': ''})
     form = ContractorDeliverableRevisionForm(self.data,
                                              instance=self.rev,
                                              category=self.category)
     self.assertFalse(form.is_valid())
     self.assertTrue('reviewers' in form.errors)
Exemple #6
0
 def test_reviewers_cannot_be_deleted_after_reviewers_step(self):
     self.rev.start_review()
     self.rev.end_reviewers_step()
     self.data.update({'reviewers': ''})
     form = ContractorDeliverableRevisionForm(
         self.data,
         instance=self.rev,
         category=self.category)
     self.assertFalse(form.is_valid())
     self.assertTrue('reviewers' in form.errors)
Exemple #7
0
    def test_approver_cannot_be_changed_after_approver_step(self):
        self.rev.start_review()
        self.rev.end_review()
        self.data.update({'approver': self.user4.id})

        form = ContractorDeliverableRevisionForm(self.data,
                                                 instance=self.rev,
                                                 category=self.category)
        self.assertFalse(form.is_valid())
        self.assertTrue('approver' in form.errors)
Exemple #8
0
    def test_approver_cannot_be_changed_after_approver_step(self):
        self.rev.start_review()
        self.rev.end_review()
        self.data.update({'approver': self.user4.id})

        form = ContractorDeliverableRevisionForm(
            self.data,
            instance=self.rev,
            category=self.category)
        self.assertFalse(form.is_valid())
        self.assertTrue('approver' in form.errors)
Exemple #9
0
    def test_reviewers_cannot_be_added_after_reviewers_step(self):
        self.rev.start_review()
        self.rev.end_reviewers_step()

        reviewers = '{},{}'.format(self.user.id, self.user4.id)
        self.data.update({'reviewers': reviewers})

        form = ContractorDeliverableRevisionForm(self.data,
                                                 instance=self.rev,
                                                 category=self.category)
        self.assertFalse(form.is_valid())
        self.assertTrue('reviewers' in form.errors)
Exemple #10
0
    def test_reviewers_cannot_be_added_after_reviewers_step(self):
        self.rev.start_review()
        self.rev.end_reviewers_step()

        reviewers = '{},{}'.format(self.user.id, self.user4.id)
        self.data.update({'reviewers': reviewers})

        form = ContractorDeliverableRevisionForm(
            self.data,
            instance=self.rev,
            category=self.category)
        self.assertFalse(form.is_valid())
        self.assertTrue('reviewers' in form.errors)
Exemple #11
0
    def test_reviewer_may_not_be_deleted_during_reviewers_step(self):
        """Reviewers that submitted a review cannot be removed."""
        self.rev.reviewers.add(self.user4)
        self.rev.start_review()

        # Post a review
        review = self.rev.get_review(self.user)
        review.post_review(comments=None)

        # Assert the reviewers stop is still open
        self.rev.refresh_from_db()
        self.assertIsNone(self.rev.reviewers_step_closed)

        # Try to remove the initial reviewer
        reviewers = str(self.user4.id)
        self.data.update({'reviewers': reviewers})
        form = ContractorDeliverableRevisionForm(self.data,
                                                 instance=self.rev,
                                                 category=self.category)
        self.assertFalse(form.is_valid())
        self.assertTrue('reviewers' in form.errors)
Exemple #12
0
    def test_reviewer_can_be_added_during_reviewers_step(self):
        self.rev.start_review()

        # Count initial Reviews
        qs = Review.objects \
            .filter(document=self.rev.document) \
            .filter(revision=self.rev.revision) \
            .filter(role='reviewer')
        self.assertEqual(qs.count(), 1)

        # Add a reviewer
        reviewers = '{},{}'.format(self.user.id, self.user4.id)
        self.data.update({'reviewers': reviewers})
        form = ContractorDeliverableRevisionForm(self.data,
                                                 instance=self.rev,
                                                 category=self.category)
        self.assertTrue(form.is_valid())
        form.save()

        # Count updated Reviews
        self.assertEqual(qs.count(), 2)
Exemple #13
0
    def test_reviewer_may_not_be_deleted_during_reviewers_step(self):
        """Reviewers that submitted a review cannot be removed."""
        self.rev.reviewers.add(self.user4)
        self.rev.start_review()

        # Post a review
        review = self.rev.get_review(self.user)
        review.post_review(comments=None)

        # Assert the reviewers stop is still open
        self.rev.refresh_from_db()
        self.assertIsNone(self.rev.reviewers_step_closed)

        # Try to remove the initial reviewer
        reviewers = str(self.user4.id)
        self.data.update({'reviewers': reviewers})
        form = ContractorDeliverableRevisionForm(
            self.data,
            instance=self.rev,
            category=self.category)
        self.assertFalse(form.is_valid())
        self.assertTrue('reviewers' in form.errors)
Exemple #14
0
    def test_reviewer_can_be_added_during_reviewers_step(self):
        self.rev.start_review()

        # Count initial Reviews
        qs = Review.objects \
            .filter(document=self.rev.document) \
            .filter(revision=self.rev.revision) \
            .filter(role='reviewer')
        self.assertEqual(qs.count(), 1)

        # Add a reviewer
        reviewers = '{},{}'.format(self.user.id, self.user4.id)
        self.data.update({'reviewers': reviewers})
        form = ContractorDeliverableRevisionForm(
            self.data,
            instance=self.rev,
            category=self.category)
        self.assertTrue(form.is_valid())
        form.save()

        # Count updated Reviews
        self.assertEqual(qs.count(), 2)
Exemple #15
0
    def test_reviewer_may_be_deleted_during_reviewers_step(self):
        """A reviewer can be deleted if they didn't submit a review yet."""
        self.rev.start_review()

        # Count initial Reviews
        qs = Review.objects \
            .filter(document=self.rev.document) \
            .filter(revision=self.rev.revision) \
            .filter(role='reviewer')
        self.assertEqual(qs.count(), 1)

        # Remove a reviewer
        reviewers = ''
        self.data.update({'reviewers': reviewers})
        form = ContractorDeliverableRevisionForm(self.data,
                                                 instance=self.rev,
                                                 category=self.category)
        self.assertTrue(form.is_valid())
        form.save()

        # Count updated Reviews
        self.assertEqual(qs.count(), 0)
Exemple #16
0
    def test_reviewer_may_be_deleted_during_reviewers_step(self):
        """A reviewer can be deleted if they didn't submit a review yet."""
        self.rev.start_review()

        # Count initial Reviews
        qs = Review.objects \
            .filter(document=self.rev.document) \
            .filter(revision=self.rev.revision) \
            .filter(role='reviewer')
        self.assertEqual(qs.count(), 1)

        # Remove a reviewer
        reviewers = ''
        self.data.update({'reviewers': reviewers})
        form = ContractorDeliverableRevisionForm(
            self.data,
            instance=self.rev,
            category=self.category)
        self.assertTrue(form.is_valid())
        form.save()

        # Count updated Reviews
        self.assertEqual(qs.count(), 0)
Exemple #17
0
 def test_review_form_is_valid(self):
     form = ContractorDeliverableRevisionForm(self.data, category=self.category)
     self.assertTrue(form.is_valid())
Exemple #18
0
 def test_review_form_is_valid(self):
     form = ContractorDeliverableRevisionForm(self.data,
                                              category=self.category)
     self.assertTrue(form.is_valid())