File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed
Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change 2525# Mock MinioClient before importing backend modules
2626with patch ('backend.database.client.MinioClient' ) as minio_mock :
2727 minio_mock .return_value = MagicMock ()
28- # Now we can safely import the function to test
29- from backend .apps .elasticsearch_app import router
30- from nexent .vector_database .elasticsearch_core import ElasticSearchCore
3128
3229
3330class SearchRequest (BaseModel ):
@@ -67,12 +64,14 @@ class IndexingResponse(BaseModel):
6764# Patch the module import before importing backend modules
6865sys .modules ['consts.model' ] = consts_model_mock
6966
70- # Now import the modules that depend on consts.model
71-
7267# Create mocks for these services if they can't be imported
7368ElasticSearchService = MagicMock ()
7469RedisService = MagicMock ()
7570
71+ # Import routes and services
72+ from backend .apps .elasticsearch_app import router
73+ from nexent .vector_database .elasticsearch_core import ElasticSearchCore
74+
7675# Create test client
7776app = FastAPI ()
7877
@@ -86,8 +85,6 @@ class IndexingResponse(BaseModel):
8685app .include_router (router )
8786client = TestClient (app )
8887
89- # Fixtures to provide mocked objects
90-
9188
9289@pytest .fixture
9390def es_core_mock ():
You can’t perform that action at this time.
0 commit comments