11import pytest
22import sys
33import types
4- from pathlib import Path
54from unittest .mock import AsyncMock , MagicMock , patch , Mock , PropertyMock
65
7- PROJECT_ROOT = Path (__file__ ).resolve ().parents [3 ]
8- if str (PROJECT_ROOT ) not in sys .path :
9- sys .path .insert (0 , str (PROJECT_ROOT ))
6+ from test .common .env_test_utils import bootstrap_env
7+
8+ env_state = bootstrap_env ()
9+ consts_const = env_state ["mock_const" ]
1010
1111# Utilities ---------------------------------------------------------------
1212def _create_stub_module (name : str , ** attrs ):
@@ -17,28 +17,21 @@ def _create_stub_module(name: str, **attrs):
1717 return module
1818
1919
20- # Mock consts module first to avoid ModuleNotFoundError
21- consts_mock = MagicMock ()
22- consts_mock .const = MagicMock ()
23- # Set required constants in consts.const
24- consts_mock .const .MINIO_ENDPOINT = "http://localhost:9000"
25- consts_mock .const .MINIO_ACCESS_KEY = "test_access_key"
26- consts_mock .const .MINIO_SECRET_KEY = "test_secret_key"
27- consts_mock .const .MINIO_REGION = "us-east-1"
28- consts_mock .const .MINIO_DEFAULT_BUCKET = "test-bucket"
29- consts_mock .const .POSTGRES_HOST = "localhost"
30- consts_mock .const .POSTGRES_USER = "test_user"
31- consts_mock .const .NEXENT_POSTGRES_PASSWORD = "test_password"
32- consts_mock .const .POSTGRES_DB = "test_db"
33- consts_mock .const .POSTGRES_PORT = 5432
34- consts_mock .const .DEFAULT_TENANT_ID = "default_tenant"
35- consts_mock .const .LOCAL_MCP_SERVER = "http://localhost:5011"
36- consts_mock .const .MODEL_CONFIG_MAPPING = {"llm" : "llm_config" }
37- consts_mock .const .LANGUAGE = {"ZH" : "zh" }
38-
39- # Add the mocked consts module to sys.modules
40- sys .modules ['consts' ] = consts_mock
41- sys .modules ['consts.const' ] = consts_mock .const
20+ # Configure required constants via shared bootstrap env
21+ consts_const .MINIO_ENDPOINT = "http://localhost:9000"
22+ consts_const .MINIO_ACCESS_KEY = "test_access_key"
23+ consts_const .MINIO_SECRET_KEY = "test_secret_key"
24+ consts_const .MINIO_REGION = "us-east-1"
25+ consts_const .MINIO_DEFAULT_BUCKET = "test-bucket"
26+ consts_const .POSTGRES_HOST = "localhost"
27+ consts_const .POSTGRES_USER = "test_user"
28+ consts_const .NEXENT_POSTGRES_PASSWORD = "test_password"
29+ consts_const .POSTGRES_DB = "test_db"
30+ consts_const .POSTGRES_PORT = 5432
31+ consts_const .DEFAULT_TENANT_ID = "default_tenant"
32+ consts_const .LOCAL_MCP_SERVER = "http://localhost:5011"
33+ consts_const .MODEL_CONFIG_MAPPING = {"llm" : "llm_config" }
34+ consts_const .LANGUAGE = {"ZH" : "zh" }
4235
4336# Mock utils module
4437utils_mock = MagicMock ()
0 commit comments