Ejemplo n.º 1
0
    def test_reindex_json_responses(self):
        """
        Test json response with real data
        """
        # Check results not indexed
        response = perform_search(
            "unique",
            user=self.user,
            size=10,
            from_=0,
            course_id=unicode(self.course.id))
        self.assertEqual(response['results'], [])

        # Start manual reindex
        reindex_course_and_check_access(self.course.id, self.user)

        self.html.display_name = "My expanded HTML"
        modulestore().update_item(self.html, ModuleStoreEnum.UserID.test)

        # Start manual reindex
        reindex_course_and_check_access(self.course.id, self.user)

        # Check results indexed now
        response = perform_search(
            "unique",
            user=self.user,
            size=10,
            from_=0,
            course_id=unicode(self.course.id))
        self.assertEqual(response['total'], 1)
Ejemplo n.º 2
0
    def test_reindex_json_responses(self):
        """
        Test json response with real data
        """
        # Check results not indexed
        response = perform_search("unique",
                                  user=self.user,
                                  size=10,
                                  from_=0,
                                  course_id=unicode(self.course.id))
        self.assertEqual(response['results'], [])

        # Start manual reindex
        reindex_course_and_check_access(self.course.id, self.user)

        self.html.display_name = "My expanded HTML"
        modulestore().update_item(self.html, ModuleStoreEnum.UserID.test)

        # Start manual reindex
        reindex_course_and_check_access(self.course.id, self.user)

        # Check results indexed now
        response = perform_search("unique",
                                  user=self.user,
                                  size=10,
                                  from_=0,
                                  course_id=unicode(self.course.id))
        self.assertEqual(response['total'], 1)
Ejemplo n.º 3
0
    def test_reindex_no_item(self, mock_get_course):
        """
        Test system logs an error if no item found.
        """
        # set mocked exception response
        err = ItemNotFoundError
        mock_get_course.return_value = err

        # Start manual reindex and check error in response
        with self.assertRaises(SearchIndexingError):
            reindex_course_and_check_access(self.course.id, self.user)
Ejemplo n.º 4
0
    def test_reindex_no_item(self, mock_get_course):
        """
        Test system logs an error if no item found.
        """
        # set mocked exception response
        err = ItemNotFoundError
        mock_get_course.return_value = err

        # Start manual reindex and check error in response
        with self.assertRaises(SearchIndexingError):
            reindex_course_and_check_access(self.course.id, self.user)
Ejemplo n.º 5
0
    def test_reindex_json_responses(self):
        """
        Test json response with real data
        """
        # results are indexed because they are published from ItemFactory
        response = perform_search("unique", user=self.user, size=10, from_=0, course_id=unicode(self.course.id))
        self.assertEqual(response["total"], 1)

        # Start manual reindex
        reindex_course_and_check_access(self.course.id, self.user)

        # Check results remain the same
        response = perform_search("unique", user=self.user, size=10, from_=0, course_id=unicode(self.course.id))
        self.assertEqual(response["total"], 1)
Ejemplo n.º 6
0
    def test_reindex_seq_error_json_responses(self, mock_index_dictionary):
        """
        Test json response with mocked error data for sequence
        """
        # results are indexed because they are published from ItemFactory
        response = perform_search("unique", user=self.user, size=10, from_=0, course_id=unicode(self.course.id))
        self.assertEqual(response["total"], 1)

        # set mocked exception response
        err = Exception
        mock_index_dictionary.return_value = err

        # Start manual reindex and check error in response
        with self.assertRaises(SearchIndexingError):
            reindex_course_and_check_access(self.course.id, self.user)
Ejemplo n.º 7
0
    def test_reindex_seq_error_json_responses(self, mock_index_dictionary):
        """
        Test json response with mocked error data for sequence
        """
        # results are indexed because they are published from ItemFactory
        response = perform_search("unique",
                                  user=self.user,
                                  size=10,
                                  from_=0,
                                  course_id=unicode(self.course.id))
        self.assertEqual(response['total'], 1)

        # set mocked exception response
        err = Exception
        mock_index_dictionary.return_value = err

        # Start manual reindex and check error in response
        with self.assertRaises(SearchIndexingError):
            reindex_course_and_check_access(self.course.id, self.user)
Ejemplo n.º 8
0
    def test_reindex_html_error_json_responses(self, mock_index_dictionary):
        """
        Test json response with mocked error data for html
        """
        # Check results not indexed
        response = perform_search("unique",
                                  user=self.user,
                                  size=10,
                                  from_=0,
                                  course_id=unicode(self.course.id))
        self.assertEqual(response['results'], [])

        # set mocked exception response
        err = SearchIndexingError
        mock_index_dictionary.return_value = err

        # Start manual reindex and check error in response
        with self.assertRaises(SearchIndexingError):
            reindex_course_and_check_access(self.course.id, self.user)
Ejemplo n.º 9
0
    def test_reindex_seq_error_json_responses(self, mock_index_dictionary):
        """
        Test json response with rmocked error data for sequence
        """
        # Check results not indexed
        response = perform_search(
            "unique",
            user=self.user,
            size=10,
            from_=0,
            course_id=unicode(self.course.id))
        self.assertEqual(response['results'], [])

        # set mocked exception response
        err = Exception
        mock_index_dictionary.return_value = err

        # Start manual reindex and check error in response
        with self.assertRaises(SearchIndexingError):
            reindex_course_and_check_access(self.course.id, self.user)
Ejemplo n.º 10
0
    def test_reindex_json_responses(self):
        """
        Test json response with real data
        """
        # results are indexed because they are published from ItemFactory
        response = perform_search("unique",
                                  user=self.user,
                                  size=10,
                                  from_=0,
                                  course_id=unicode(self.course.id))
        self.assertEqual(response['total'], 1)

        # Start manual reindex
        reindex_course_and_check_access(self.course.id, self.user)

        # Check results remain the same
        response = perform_search("unique",
                                  user=self.user,
                                  size=10,
                                  from_=0,
                                  course_id=unicode(self.course.id))
        self.assertEqual(response['total'], 1)
Ejemplo n.º 11
0
 def test_reindex_no_permissions(self):
     # register a non-staff member and try to delete the course branch
     user2 = UserFactory()
     with self.assertRaises(PermissionDenied):
         reindex_course_and_check_access(self.course.id, user2)
Ejemplo n.º 12
0
 def test_reindex_no_permissions(self):
     # register a non-staff member and try to delete the course branch
     user2 = UserFactory()
     with self.assertRaises(PermissionDenied):
         reindex_course_and_check_access(self.course.id, user2)