Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 4
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)
Esempio n. 5
0
 def tearDown(self):
     MockSearchEngine.destroy_test_file()
     self._searcher = None
     super(FileBackedMockSearchTests, self).tearDown()
Esempio n. 6
0
 def setUp(self):
     super(FileBackedMockSearchTests, self).setUp()
     MockSearchEngine.create_test_file()
     self._searcher = None
Esempio n. 7
0
 def tearDown(self):
     MockSearchEngine.destroy()
     super().tearDown()
Esempio n. 8
0
 def setUp(self):
     super(BadIndexTest, self).setUp()
     MockSearchEngine.destroy()
Esempio n. 9
0
 def setUp(self):
     super(BadIndexTest, self).setUp()
     MockSearchEngine.destroy()
Esempio n. 10
0
 def setUp(self):
     super().setUp()
     MockSearchEngine.create_test_file()
     self._searcher = None
Esempio n. 11
0
 def tearDown(self):
     MockSearchEngine.destroy()
Esempio n. 12
0
 def setUp(self):
     MockSearchEngine.destroy()
Esempio n. 13
0
 def tearDown(self):
     MockSearchEngine.destroy()
     self._searcher = None
Esempio n. 14
0
 def tearDown(self):
     MockSearchEngine.destroy_test_file()
     self._searcher = None
     super(FileBackedMockSearchTests, self).tearDown()
Esempio n. 15
0
 def setUp(self):
     super(FileBackedMockSearchTests, self).setUp()
     MockSearchEngine.create_test_file()
     self._searcher = None
Esempio n. 16
0
 def tearDown(self):
     MockSearchEngine.destroy_test_file()
     self._searcher = None
     super().tearDown()
Esempio n. 17
0
 def tearDown(self):
     MockSearchEngine.destroy()
     self._searcher = None
     super(MockSearchUrlTest, self).tearDown()
Esempio n. 18
0
 def tearDown(self):
     MockSearchEngine.destroy()
     self._searcher = None
Esempio n. 19
0
 def tearDown(self):
     MockSearchEngine.destroy()
     super(BadIndexTest, self).tearDown()
Esempio n. 20
0
 def setUp(self):
     MockSearchEngine.destroy()
Esempio n. 21
0
 def tearDown(self):
     MockSearchEngine.destroy()
     self._searcher = None
     super(MockSearchUrlTest, self).tearDown()
Esempio n. 22
0
 def tearDown(self):
     MockSearchEngine.destroy()
Esempio n. 23
0
 def tearDown(self):
     MockSearchEngine.destroy()
     super(BadIndexTest, self).tearDown()
Esempio n. 24
0
 def setUp(self):
     super().setUp()
     MockSearchEngine.destroy()