Skip to content

Commit 783491d

Browse files
author
jiangpeiling
committed
♻️ Reconstruct the app layer and service layer to comply with the MVC three-layer architecture.
1 parent 333942e commit 783491d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

test/backend/app/test_elasticsearch_app.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
# Mock MinioClient before importing backend modules
2626
with 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

3330
class SearchRequest(BaseModel):
@@ -67,12 +64,14 @@ class IndexingResponse(BaseModel):
6764
# Patch the module import before importing backend modules
6865
sys.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
7368
ElasticSearchService = MagicMock()
7469
RedisService = 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
7776
app = FastAPI()
7877

@@ -86,8 +85,6 @@ class IndexingResponse(BaseModel):
8685
app.include_router(router)
8786
client = TestClient(app)
8887

89-
# Fixtures to provide mocked objects
90-
9188

9289
@pytest.fixture
9390
def es_core_mock():

0 commit comments

Comments
 (0)