Ejemplo n.º 1
0
    def test_get_cohorted_commentables(self):
        """
        Make sure cohorts.get_cohorted_commentables() correctly returns a list of strings representing cohorted
        commentables.  Also verify that we can't get the cohorted commentables from a course which does not exist.
        """
        course = modulestore().get_course(self.toy_course_key)

        self.assertEqual(cohorts.get_cohorted_commentables(course.id), set())

        config_course_cohorts(course, [], cohorted=True)
        self.assertEqual(cohorts.get_cohorted_commentables(course.id), set())

        config_course_cohorts(
            course, ["General", "Feedback"],
            cohorted=True,
            cohorted_discussions=["Feedback"]
        )
        self.assertItemsEqual(
            cohorts.get_cohorted_commentables(course.id),
            set([topic_name_to_id(course, "Feedback")])
        )

        config_course_cohorts(
            course, ["General", "Feedback"],
            cohorted=True,
            cohorted_discussions=["General", "Feedback"]
        )
        self.assertItemsEqual(
            cohorts.get_cohorted_commentables(course.id),
            set([topic_name_to_id(course, "General"), topic_name_to_id(course, "Feedback")])
        )
        self.assertRaises(
            Http404,
            lambda: cohorts.get_cohorted_commentables(SlashSeparatedCourseKey("course", "does_not", "exist"))
        )
Ejemplo n.º 2
0
    def test_get_cohorted_commentables(self):
        """
        Make sure cohorts.get_cohorted_commentables() correctly returns a list of strings representing cohorted
        commentables.  Also verify that we can't get the cohorted commentables from a course which does not exist.
        """
        course = modulestore().get_course(self.toy_course_key)

        self.assertEqual(cohorts.get_cohorted_commentables(course.id), set())

        config_course_cohorts(course, [], cohorted=True)
        self.assertEqual(cohorts.get_cohorted_commentables(course.id), set())

        config_course_cohorts(course, ["General", "Feedback"],
                              cohorted=True,
                              cohorted_discussions=["Feedback"])
        self.assertItemsEqual(cohorts.get_cohorted_commentables(course.id),
                              set([topic_name_to_id(course, "Feedback")]))

        config_course_cohorts(course, ["General", "Feedback"],
                              cohorted=True,
                              cohorted_discussions=["General", "Feedback"])
        self.assertItemsEqual(
            cohorts.get_cohorted_commentables(course.id),
            set([
                topic_name_to_id(course, "General"),
                topic_name_to_id(course, "Feedback")
            ]))
        self.assertRaises(
            Http404, lambda: cohorts.get_cohorted_commentables(
                SlashSeparatedCourseKey("course", "does_not", "exist")))
Ejemplo n.º 3
0
 def to_id(name):
     return topic_name_to_id(course, name)
Ejemplo n.º 4
0
 def to_id(name):
     return topic_name_to_id(course, name)