def test_location_parameter(self):
        srp = LmsSearchResultProcessor(
            {
                "course": unicode(self.course.id),
                "id": unicode(self.html.scope_ids.usage_id),
                "content": {
                    "text": "This is html test text"
                }
            }, "test")

        self.assertEqual(len(srp.location), 3)
        self.assertEqual(srp.location[0], 'Test Section')
        self.assertEqual(srp.location[1], 'Test Subsection')
        self.assertEqual(srp.location[2], 'Test Unit')

        srp = LmsSearchResultProcessor(
            {
                "course": unicode(self.course.id),
                "id": unicode(self.vertical.scope_ids.usage_id),
                "content": {
                    "text": "This is html test text"
                }
            }, "test")

        self.assertEqual(len(srp.location), 3)
        self.assertEqual(srp.location[0], 'Test Section')
        self.assertEqual(srp.location[1], 'Test Subsection')
        self.assertEqual(srp.location[2], 'Test Unit')

        srp = LmsSearchResultProcessor(
            {
                "course": unicode(self.course.id),
                "id": unicode(self.subsection.scope_ids.usage_id),
                "content": {
                    "text": "This is html test text"
                }
            }, "test")

        self.assertEqual(len(srp.location), 2)
        self.assertEqual(srp.location[0], 'Test Section')
        self.assertEqual(srp.location[1], 'Test Subsection')

        srp = LmsSearchResultProcessor(
            {
                "course": unicode(self.course.id),
                "id": unicode(self.section.scope_ids.usage_id),
                "content": {
                    "text": "This is html test text"
                }
            }, "test")

        self.assertEqual(len(srp.location), 1)
        self.assertEqual(srp.location[0], 'Test Section')
    def test_should_remove(self):
        """
        Tests that "visible_to_staff_only" overrides start date.
        """
        srp = LmsSearchResultProcessor(
            {
                "course": str(self.course.id),
                "id": str(self.html.scope_ids.usage_id),
                "content": {
                    "text": "This is html test text"
                }
            }, "test")

        assert srp.should_remove(self.global_staff) is False
    def test_should_remove(self):
        """
        Tests that "visible_to_staff_only" overrides start date.
        """
        srp = LmsSearchResultProcessor(
            {
                "course": unicode(self.course.id),
                "id": unicode(self.html.scope_ids.usage_id),
                "content": {"text": "This is html test text"}
            },
            "test"
        )

        self.assertEqual(srp.should_remove(self.global_staff), False)
    def test_url_parameter(self):
        fake_url = ""
        srp = LmsSearchResultProcessor({}, "test")
        with pytest.raises(ValueError):
            fake_url = srp.url
        assert fake_url == ''

        srp = LmsSearchResultProcessor(
            {
                "course": str(self.course.id),
                "id": str(self.html.scope_ids.usage_id),
                "content": {
                    "text": "This is the html text"
                }
            }, "test")

        assert srp.url == '/courses/{}/jump_to/{}'.format(
            str(self.course.id), str(self.html.scope_ids.usage_id))
Beispiel #5
0
    def test_url_parameter(self):
        fake_url = ""
        srp = LmsSearchResultProcessor({}, "test")
        with self.assertRaises(ValueError):
            fake_url = srp.url
        self.assertEqual(fake_url, "")

        srp = LmsSearchResultProcessor(
            {
                "course": unicode(self.course.id),
                "id": unicode(self.html.scope_ids.usage_id),
                "content": {"text": "This is the html text"}
            },
            "test"
        )

        self.assertEqual(
            srp.url, "/courses/{}/jump_to/{}".format(unicode(self.course.id), unicode(self.html.scope_ids.usage_id)))
Beispiel #6
0
 def test_course_name_parameter(self):
     srp = LmsSearchResultProcessor(
         {
             "course": unicode(self.course.id),
             "id": unicode(self.html.scope_ids.usage_id),
             "content": {"text": "This is the html text"}
         },
         "test"
     )
     self.assertEqual(srp.course_name, self.course.display_name)
Beispiel #7
0
    def test_missing_display_name(self):
        """
        Tests that we get the correct name to include when there is an empty or null display name
        """
        srp = LmsSearchResultProcessor(
            {
                "course": unicode(self.course.id),
                "id": unicode(self.ghost_html.scope_ids.usage_id),
                "content": {"text": "This is html test text"}
            },
            "test"
        )

        location = srp.location
        self.assertEqual(len(location), 3)
        self.assertEqual(location[0], self.section.display_name)
        self.assertEqual(location[1], UNNAMED_MODULE_NAME)
        self.assertEqual(location[2], UNNAMED_MODULE_NAME)