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