Skip to content

Commit

Permalink
Add nidx dummy fixture for testing (#2639)
Browse files Browse the repository at this point in the history
  • Loading branch information
javitonino committed Nov 22, 2024
1 parent 91d9fb2 commit 18f38bf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nucliadb/tests/ingest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from nucliadb.common.cluster.settings import settings as cluster_settings
from nucliadb.common.ids import FIELD_TYPE_STR_TO_PB
from nucliadb.common.maindb.driver import Driver
from nucliadb.common.nidx import NIDX_ENABLED, NidxUtility
from nucliadb.ingest.consumer import service as consumer_service
from nucliadb.ingest.fields.base import Field
from nucliadb.ingest.orm.knowledgebox import KnowledgeBox
Expand Down Expand Up @@ -270,6 +271,26 @@ async def indexing_utility(natsd, _clean_natsd):
await indexing_utility.finalize()


@pytest.fixture(scope="function")
async def dummy_nidx_utility():
class DummyNidxUtility(NidxUtility):
async def initialize(self):
pass

async def finalize(self):
pass

async def index(self, msg):
pass

if NIDX_ENABLED:
set_utility(Utility.NIDX, DummyNidxUtility())

yield

clean_utility(Utility.NIDX)


@pytest.fixture(scope="function")
async def _clean_natsd(natsd):
nc = await nats.connect(servers=[natsd])
Expand Down
1 change: 1 addition & 0 deletions nucliadb/tests/ndbfixtures/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async def component_nucliadb_reader(
# this fixture. This should be fixed or explained
local_files,
dummy_index_node_cluster,
dummy_nidx_utility,
reader_api_server: FastAPI,
) -> AsyncIterator[AsyncClient]:
with patch.object(running_settings, "debug", False):
Expand Down
1 change: 1 addition & 0 deletions nucliadb/tests/writer/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async def writer_api(
transaction_utility,
processing_utility,
tus_manager,
dummy_nidx_utility,
) -> AsyncIterator[Callable[[list[Enum], str, str], AsyncClient]]:
nucliadb_settings.nucliadb_ingest = grpc_servicer.host
from nucliadb.writer.app import create_application
Expand Down

0 comments on commit 18f38bf

Please sign in to comment.