Python ContentReviewForm Example

Introduction

The python contentreviewform example is extracted from the most popular open source projects, you can refer to the following example for usage.

Programming language: Python

Namespace/package name: orbreviewforms

Example#1
File: test_forms.pyProject: wellfire/django-orb

 def test_approve_missing_criteria(self):
     """Approval should not be valid if not all criteria are selected"""
     form = ContentReviewForm(data={
         'approved': True,
         'criteria': [self.criteria_2.pk, self.criteria_5.pk, self.criteria_6.pk],
     }, user=self.staff_user)
     self.assertFalse(form.is_valid())

Example#2
File: test_forms.pyProject: wellfire/django-orb

    def test_reject_without_reason(self):
        """Form should require reason if resource rejected"""
        form = ContentReviewForm(data={'approved': False}, user=self.staff_user)
        self.assertFalse(form.is_valid())

        form = ContentReviewForm(data={'approved': False, 'notes': ''}, user=self.staff_user)
        self.assertFalse(form.is_valid())

Example#3
File: test_forms.pyProject: wellfire/django-orb

 def test_reject_with_all_criteria(self):
     """It should be possible to reject with all criteria selected"""
     form = ContentReviewForm(data={
         'approved': False,
         'notes': 'Bad content!',
         'criteria': [self.criteria_1.pk, self.criteria_2.pk, self.criteria_5.pk, self.criteria_6.pk],
     }, user=self.staff_user)
     self.assertTrue(form.is_valid())

Example#4
File: test_forms.pyProject: wellfire/django-orb

 def test_approve_with_all_criteria(self):
     """Approval should be valid if all criteria are selected"""
     form = ContentReviewForm(data={
         'approved': True,
         'criteria': [
             c.pk for c in
             ResourceCriteria.criteria.for_roles(*self.staff_user.userprofile.reviewer_roles.all())
         ]
     }, user=self.staff_user)
     form.is_valid()
     self.assertTrue(form.is_valid())