예제 #1
0
    def test_clean_tag_course_matched(self):
        course1_tag = factories.ParticipationTagFactory(course=self.course1)

        data = {
            "user": self.test_user.pk,
            "course": self.course1.pk,
            "status": constants.participation_status.active,
            "enroll_time": now(),
            "time_factor": 1,
            "tags": [course1_tag]
        }
        form = admin.ParticipationForm(data=data)
        self.assertTrue(form.is_valid())
예제 #2
0
    def test_clean_tag_course_not_match(self):
        course1_tag = factories.ParticipationTagFactory(course=self.course1)

        data = {
            "user": self.test_user.pk,
            "course": self.course2.pk,
            "status": constants.participation_status.active,
            "enroll_time": now(),
            "time_factor": 1,
            "tags": [course1_tag]
        }
        form = admin.ParticipationForm(data=data)
        self.assertFalse(form.is_valid())
        expected_error_msg = "Tags must belong to same course as participation."
        self.assertIn(expected_error_msg, str(form.errors))
예제 #3
0
 def test_unicode(self):
     tag1 = factories.ParticipationTagFactory(course=self.course,
                                              name="tag1")
     tag2 = factories.ParticipationTagFactory(course=self.course,
                                              name="tag2")
     self.assertNotEqual(str(tag1), str(tag2))