def test_topic_tags(self): tags = ['new hero', 'rules', 'new version', 'hero update', 'bug'] topic = TopicFactory() for tag in tags: tag_object = TagFactory(name=tag) topic.tags.add(tag_object) topic_tags = topic.tags.all() self.assertEqual(topic_tags.count(), len(tags))
def setUpTestData(cls): cls.category_1 = CategoryFactory(name="Cat 1") cls.tag_1 = TagFactory(name="Tag 1") cls.tag_2 = TagFactory(name="Tag 2") cls.question_1 = QuestionFactory( text="Q 1", category=cls.category_1, author="author 1", validation_status=constants.QUESTION_VALIDATION_STATUS_IN_PROGRESS, ) cls.question_2 = QuestionFactory( text="Q 2", category=cls.category_1, answer_correct="a", author="author 2", ) cls.question_2.tags.set([cls.tag_2, cls.tag_1]) cls.question_3 = QuestionFactory( text="Q 3", category=cls.category_1, author="author 3" ) cls.question_3.tags.add(cls.tag_2) cls.question_3.save() cls.quiz_1 = QuizFactory(name="quiz 1", publish=False) QuizQuestion.objects.create(quiz=cls.quiz_1, question=cls.question_1) cls.quiz_2 = QuizFactory(name="quiz 2", publish=True) QuizQuestion.objects.create(quiz=cls.quiz_2, question=cls.question_2, order=2) QuizQuestion.objects.create(quiz=cls.quiz_2, question=cls.question_3, order=1)