Exemple #1
0
 def setUp(self):
     super(MockSearchUrlTest, self).setUp()
     MockSearchEngine.destroy()
     self._searcher = None
     patcher = patch('search.views.track')
     self.mock_tracker = patcher.start()
     self.addCleanup(patcher.stop)
Exemple #2
0
 def setUp(self):
     super(MockSearchUrlTest, self).setUp()
     MockSearchEngine.destroy()
     self._searcher = None
     patcher = patch('search.views.track')
     self.mock_tracker = patcher.start()
     self.addCleanup(patcher.stop)
Exemple #3
0
    def test_disabled_index(self):
        """
        Make sure that searchengine operations are shut down when mock engine has a filename, but file does
        not exist - this is helpful for test scenarios where we essentially want to not slow anything down
        """
        this_moment = datetime.utcnow()
        test_object = {
            "id":
            "FAKE_ID",
            "content": {
                "name": "How did 11 of 12 balls get deflated during the game"
            },
            "my_date_value":
            this_moment,
            "my_integer_value":
            172,
            "my_float_value":
            57.654,
            "my_string_value":
            "If the officials just blew it, would they come out and admit it?"
        }

        self.searcher.index("test_doc", [test_object])
        response = self.searcher.search(query_string="deflated")
        self.assertEqual(response["total"], 1)

        # copy content, and then erase file so that backed file is not present and work is disabled
        initial_file_content = None
        with open("testfile.pkl", "r") as dict_file:
            initial_file_content = json.load(dict_file)
        os.remove("testfile.pkl")

        response = self.searcher.search(query_string="ABC")
        self.assertEqual(response["total"], 0)

        self.searcher.index("test_doc", [{"content": {"name": "ABC"}}])
        # now search should be unsuccessful because file does not exist
        response = self.searcher.search(query_string="ABC")
        self.assertEqual(response["total"], 0)

        # remove it, and then we'll reload file and it still should be there
        self.searcher.remove("test_doc", ["FAKE_ID"])

        MockSearchEngine.create_test_file("fakefile.pkl", initial_file_content)

        # now search should be successful because file did exist in file
        response = self.searcher.search(query_string="deflated")
        self.assertEqual(response["total"], 1)

        self.searcher.remove("not_a_test_doc", ["FAKE_ID"])
        response = self.searcher.search(query_string="deflated")
        self.assertEqual(response["total"], 1)

        self.searcher.remove("test_doc", ["FAKE_ID"])
        response = self.searcher.search(query_string="deflated")
        self.assertEqual(response["total"], 0)
    def test_disabled_index(self):
        """
        Make sure that searchengine operations are shut down when mock engine has a filename, but file does
        not exist - this is helpful for test scenarios where we essentially want to not slow anything down
        """
        this_moment = datetime.utcnow()
        test_object = {
            "id": "FAKE_ID",
            "content": {
                "name": "How did 11 of 12 balls get deflated during the game"
            },
            "my_date_value": this_moment,
            "my_integer_value": 172,
            "my_float_value": 57.654,
            "my_string_value": "If the officials just blew it, would they come out and admit it?"
        }

        self.searcher.index("test_doc", [test_object])
        response = self.searcher.search(query_string="deflated")
        self.assertEqual(response["total"], 1)

        # copy content, and then erase file so that backed file is not present and work is disabled
        initial_file_content = None
        with open("testfile.pkl", "r") as dict_file:
            initial_file_content = json.load(dict_file)
        os.remove("testfile.pkl")

        response = self.searcher.search(query_string="ABC")
        self.assertEqual(response["total"], 0)

        self.searcher.index("test_doc", [{"content": {"name": "ABC"}}])
        # now search should be unsuccessful because file does not exist
        response = self.searcher.search(query_string="ABC")
        self.assertEqual(response["total"], 0)

        # remove it, and then we'll reload file and it still should be there
        self.searcher.remove("test_doc", ["FAKE_ID"])

        MockSearchEngine.create_test_file("fakefile.pkl", initial_file_content)

        # now search should be successful because file did exist in file
        response = self.searcher.search(query_string="deflated")
        self.assertEqual(response["total"], 1)

        self.searcher.remove("not_a_test_doc", ["FAKE_ID"])
        response = self.searcher.search(query_string="deflated")
        self.assertEqual(response["total"], 1)

        self.searcher.remove("test_doc", ["FAKE_ID"])
        response = self.searcher.search(query_string="deflated")
        self.assertEqual(response["total"], 0)
 def tearDown(self):
     MockSearchEngine.destroy_test_file()
     self._searcher = None
     super(FileBackedMockSearchTests, self).tearDown()
 def setUp(self):
     super(FileBackedMockSearchTests, self).setUp()
     MockSearchEngine.create_test_file()
     self._searcher = None
Exemple #7
0
 def tearDown(self):
     MockSearchEngine.destroy()
     super().tearDown()
Exemple #8
0
 def setUp(self):
     super(BadIndexTest, self).setUp()
     MockSearchEngine.destroy()
Exemple #9
0
 def setUp(self):
     super(BadIndexTest, self).setUp()
     MockSearchEngine.destroy()
 def setUp(self):
     super().setUp()
     MockSearchEngine.create_test_file()
     self._searcher = None
 def tearDown(self):
     MockSearchEngine.destroy()
 def setUp(self):
     MockSearchEngine.destroy()
 def tearDown(self):
     MockSearchEngine.destroy()
     self._searcher = None
Exemple #14
0
 def tearDown(self):
     MockSearchEngine.destroy_test_file()
     self._searcher = None
     super(FileBackedMockSearchTests, self).tearDown()
Exemple #15
0
 def setUp(self):
     super(FileBackedMockSearchTests, self).setUp()
     MockSearchEngine.create_test_file()
     self._searcher = None
 def tearDown(self):
     MockSearchEngine.destroy_test_file()
     self._searcher = None
     super().tearDown()
Exemple #17
0
 def tearDown(self):
     MockSearchEngine.destroy()
     self._searcher = None
     super(MockSearchUrlTest, self).tearDown()
Exemple #18
0
 def tearDown(self):
     MockSearchEngine.destroy()
     self._searcher = None
Exemple #19
0
 def tearDown(self):
     MockSearchEngine.destroy()
     super(BadIndexTest, self).tearDown()
Exemple #20
0
 def setUp(self):
     MockSearchEngine.destroy()
Exemple #21
0
 def tearDown(self):
     MockSearchEngine.destroy()
     self._searcher = None
     super(MockSearchUrlTest, self).tearDown()
Exemple #22
0
 def tearDown(self):
     MockSearchEngine.destroy()
Exemple #23
0
 def tearDown(self):
     MockSearchEngine.destroy()
     super(BadIndexTest, self).tearDown()
Exemple #24
0
 def setUp(self):
     super().setUp()
     MockSearchEngine.destroy()