|
7 | 7 | import os |
8 | 8 | from unittest.mock import MagicMock, patch |
9 | 9 |
|
10 | | -# Patch environment variables before any imports that might use them |
11 | | -os.environ.setdefault('MINIO_ENDPOINT', 'http://localhost:9000') |
12 | | -os.environ.setdefault('MINIO_ACCESS_KEY', 'minioadmin') |
13 | | -os.environ.setdefault('MINIO_SECRET_KEY', 'minioadmin') |
14 | | -os.environ.setdefault('MINIO_REGION', 'us-east-1') |
15 | | -os.environ.setdefault('MINIO_DEFAULT_BUCKET', 'test-bucket') |
| 10 | +# Mock consts module before patching backend.database.client to avoid ImportError |
| 11 | +# backend.database.client imports from consts.const, so we need to mock it first |
| 12 | +consts_mock = MagicMock() |
| 13 | +consts_const_mock = MagicMock() |
| 14 | +# Set required constants that backend.database.client might use |
| 15 | +consts_const_mock.MINIO_ENDPOINT = "http://localhost:9000" |
| 16 | +consts_const_mock.MINIO_ACCESS_KEY = "test_access_key" |
| 17 | +consts_const_mock.MINIO_SECRET_KEY = "test_secret_key" |
| 18 | +consts_const_mock.MINIO_REGION = "us-east-1" |
| 19 | +consts_const_mock.MINIO_DEFAULT_BUCKET = "test-bucket" |
| 20 | +consts_const_mock.POSTGRES_HOST = "localhost" |
| 21 | +consts_const_mock.POSTGRES_USER = "test_user" |
| 22 | +consts_const_mock.NEXENT_POSTGRES_PASSWORD = "test_password" |
| 23 | +consts_const_mock.POSTGRES_DB = "test_db" |
| 24 | +consts_const_mock.POSTGRES_PORT = 5432 |
| 25 | +consts_mock.const = consts_const_mock |
| 26 | +sys.modules['consts'] = consts_mock |
| 27 | +sys.modules['consts.const'] = consts_const_mock |
16 | 28 |
|
17 | 29 | # Patch storage factory and MinIO config validation to avoid errors during initialization |
18 | 30 | # These patches must be started before any imports that use MinioClient |
|
0 commit comments