def test_remove_one_tag(self): course = Course.objects.get(pk=1) new_tags = 'HEAT, ANC' coursetag_count_start = CourseTag.objects.filter(course=course).count() tag_count_start = Tag.objects.all().count() request_post = { 'tags': new_tags, 'is_draft': course.is_draft, } form = UploadCourseStep2Form(request_post) self.assertEqual(form.is_valid(), True) update_course_tags(form, course, self.admin_user) coursetag_count_end = CourseTag.objects.filter(course=course).count() self.assertEqual(coursetag_count_start - 1, coursetag_count_end) tag_count_end = Tag.objects.all().count() self.assertEqual(tag_count_start, tag_count_end)
def test_add_tags(self): course = Course.objects.get(pk=1) new_tags = course.get_tags() + ', my new tag, another new tag' coursetag_count_start = CourseTag.objects.filter(course=course).count() tag_count_start = Tag.objects.all().count() request_post = { 'tags': new_tags, 'is_draft': course.is_draft, } form = UploadCourseStep2Form(request_post) self.assertEqual(form.is_valid(), True) update_course_tags(form, course, self.admin_user) coursetag_count_end = CourseTag.objects.filter(course=course).count() self.assertEqual(coursetag_count_start + 2, coursetag_count_end) tag_count_end = Tag.objects.all().count() self.assertEqual(tag_count_start + 2, tag_count_end)