From 24622e3957a4a6bd15e331b0fed277da78e18610 Mon Sep 17 00:00:00 2001 From: Rishi Diwan Date: Wed, 20 Sep 2023 15:41:14 +0530 Subject: [PATCH] Fixed api test cases --- tests/api/test_scripts.py | 5 +++-- tests/fixtures/search.py | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/api/test_scripts.py b/tests/api/test_scripts.py index a47f84b4b6..5f6ba50b57 100644 --- a/tests/api/test_scripts.py +++ b/tests/api/test_scripts.py @@ -407,6 +407,7 @@ def test_do_generate( external_search_fixture: ExternalSearchFixture, ): db = lane_script_fixture.db + external_search_fixture.init_indices() # When it's time to generate a feed, AcquisitionFeed.groups # is called with the right arguments. @@ -814,8 +815,8 @@ def test_initialize_search_indexes( def mockable_search(*args): return _mockable_search - # Initially this should be an empty index - assert search.search_service().read_pointer() == f"{base_name}-empty" + # Initially this should not exist, if InstanceInit has not been run + assert search.search_service().read_pointer() == None with patch("scripts.ExternalSearchIndex", new=mockable_search): # To fake "no migration is available", mock all the values diff --git a/tests/fixtures/search.py b/tests/fixtures/search.py index 5de936fe65..0936d273aa 100644 --- a/tests/fixtures/search.py +++ b/tests/fixtures/search.py @@ -82,6 +82,10 @@ def default_work(self, *args, **kwargs): work.set_presentation_ready() return work + def init_indices(self): + client = ExternalSearchIndex(self.db.session) + client.initialize_indices() + @pytest.fixture(scope="function") def external_search_fixture(