Skip to content

Commit 59c2b39

Browse files
committed
♻️ All models should use nexent.core.model instead of smolagent #1971
[Specification Details] 1.fix test cases.
1 parent 87b7885 commit 59c2b39

File tree

5 files changed

+90
-30
lines changed

5 files changed

+90
-30
lines changed

test/backend/test_cluster_summarization.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,24 @@
1010
import numpy as np
1111
import pytest
1212

13-
# Patch environment variables before any imports that might use them
14-
os.environ.setdefault('MINIO_ENDPOINT', 'http://localhost:9000')
15-
os.environ.setdefault('MINIO_ACCESS_KEY', 'minioadmin')
16-
os.environ.setdefault('MINIO_SECRET_KEY', 'minioadmin')
17-
os.environ.setdefault('MINIO_REGION', 'us-east-1')
18-
os.environ.setdefault('MINIO_DEFAULT_BUCKET', 'test-bucket')
13+
# Mock consts module before patching backend.database.client to avoid ImportError
14+
# backend.database.client imports from consts.const, so we need to mock it first
15+
consts_mock = MagicMock()
16+
consts_const_mock = MagicMock()
17+
# Set required constants that backend.database.client might use
18+
consts_const_mock.MINIO_ENDPOINT = "http://localhost:9000"
19+
consts_const_mock.MINIO_ACCESS_KEY = "test_access_key"
20+
consts_const_mock.MINIO_SECRET_KEY = "test_secret_key"
21+
consts_const_mock.MINIO_REGION = "us-east-1"
22+
consts_const_mock.MINIO_DEFAULT_BUCKET = "test-bucket"
23+
consts_const_mock.POSTGRES_HOST = "localhost"
24+
consts_const_mock.POSTGRES_USER = "test_user"
25+
consts_const_mock.NEXENT_POSTGRES_PASSWORD = "test_password"
26+
consts_const_mock.POSTGRES_DB = "test_db"
27+
consts_const_mock.POSTGRES_PORT = 5432
28+
consts_mock.const = consts_const_mock
29+
sys.modules['consts'] = consts_mock
30+
sys.modules['consts.const'] = consts_const_mock
1931

2032
# Patch storage factory and MinIO config validation to avoid errors during initialization
2133
# These patches must be started before any imports that use MinioClient

test/backend/test_document_vector_integration.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,24 @@
1111
import numpy as np
1212
import pytest
1313

14-
# Patch environment variables before any imports that might use them
15-
os.environ.setdefault('MINIO_ENDPOINT', 'http://localhost:9000')
16-
os.environ.setdefault('MINIO_ACCESS_KEY', 'minioadmin')
17-
os.environ.setdefault('MINIO_SECRET_KEY', 'minioadmin')
18-
os.environ.setdefault('MINIO_REGION', 'us-east-1')
19-
os.environ.setdefault('MINIO_DEFAULT_BUCKET', 'test-bucket')
14+
# Mock consts module before patching backend.database.client to avoid ImportError
15+
# backend.database.client imports from consts.const, so we need to mock it first
16+
consts_mock = MagicMock()
17+
consts_const_mock = MagicMock()
18+
# Set required constants that backend.database.client might use
19+
consts_const_mock.MINIO_ENDPOINT = "http://localhost:9000"
20+
consts_const_mock.MINIO_ACCESS_KEY = "test_access_key"
21+
consts_const_mock.MINIO_SECRET_KEY = "test_secret_key"
22+
consts_const_mock.MINIO_REGION = "us-east-1"
23+
consts_const_mock.MINIO_DEFAULT_BUCKET = "test-bucket"
24+
consts_const_mock.POSTGRES_HOST = "localhost"
25+
consts_const_mock.POSTGRES_USER = "test_user"
26+
consts_const_mock.NEXENT_POSTGRES_PASSWORD = "test_password"
27+
consts_const_mock.POSTGRES_DB = "test_db"
28+
consts_const_mock.POSTGRES_PORT = 5432
29+
consts_mock.const = consts_const_mock
30+
sys.modules['consts'] = consts_mock
31+
sys.modules['consts.const'] = consts_const_mock
2032

2133
# Patch storage factory and MinIO config validation to avoid errors during initialization
2234
# These patches must be started before any imports that use MinioClient

test/backend/test_document_vector_utils.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,24 @@
1010
import numpy as np
1111
import pytest
1212

13-
# Patch environment variables before any imports that might use them
14-
os.environ.setdefault('MINIO_ENDPOINT', 'http://localhost:9000')
15-
os.environ.setdefault('MINIO_ACCESS_KEY', 'minioadmin')
16-
os.environ.setdefault('MINIO_SECRET_KEY', 'minioadmin')
17-
os.environ.setdefault('MINIO_REGION', 'us-east-1')
18-
os.environ.setdefault('MINIO_DEFAULT_BUCKET', 'test-bucket')
13+
# Mock consts module before patching backend.database.client to avoid ImportError
14+
# backend.database.client imports from consts.const, so we need to mock it first
15+
consts_mock = MagicMock()
16+
consts_const_mock = MagicMock()
17+
# Set required constants that backend.database.client might use
18+
consts_const_mock.MINIO_ENDPOINT = "http://localhost:9000"
19+
consts_const_mock.MINIO_ACCESS_KEY = "test_access_key"
20+
consts_const_mock.MINIO_SECRET_KEY = "test_secret_key"
21+
consts_const_mock.MINIO_REGION = "us-east-1"
22+
consts_const_mock.MINIO_DEFAULT_BUCKET = "test-bucket"
23+
consts_const_mock.POSTGRES_HOST = "localhost"
24+
consts_const_mock.POSTGRES_USER = "test_user"
25+
consts_const_mock.NEXENT_POSTGRES_PASSWORD = "test_password"
26+
consts_const_mock.POSTGRES_DB = "test_db"
27+
consts_const_mock.POSTGRES_PORT = 5432
28+
consts_mock.const = consts_const_mock
29+
sys.modules['consts'] = consts_mock
30+
sys.modules['consts.const'] = consts_const_mock
1931

2032
# Patch storage factory and MinIO config validation to avoid errors during initialization
2133
# These patches must be started before any imports that use MinioClient

test/backend/test_document_vector_utils_coverage.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,24 @@
1010
import numpy as np
1111
import pytest
1212

13-
# Patch environment variables before any imports that might use them
14-
os.environ.setdefault('MINIO_ENDPOINT', 'http://localhost:9000')
15-
os.environ.setdefault('MINIO_ACCESS_KEY', 'minioadmin')
16-
os.environ.setdefault('MINIO_SECRET_KEY', 'minioadmin')
17-
os.environ.setdefault('MINIO_REGION', 'us-east-1')
18-
os.environ.setdefault('MINIO_DEFAULT_BUCKET', 'test-bucket')
13+
# Mock consts module before patching backend.database.client to avoid ImportError
14+
# backend.database.client imports from consts.const, so we need to mock it first
15+
consts_mock = MagicMock()
16+
consts_const_mock = MagicMock()
17+
# Set required constants that backend.database.client might use
18+
consts_const_mock.MINIO_ENDPOINT = "http://localhost:9000"
19+
consts_const_mock.MINIO_ACCESS_KEY = "test_access_key"
20+
consts_const_mock.MINIO_SECRET_KEY = "test_secret_key"
21+
consts_const_mock.MINIO_REGION = "us-east-1"
22+
consts_const_mock.MINIO_DEFAULT_BUCKET = "test-bucket"
23+
consts_const_mock.POSTGRES_HOST = "localhost"
24+
consts_const_mock.POSTGRES_USER = "test_user"
25+
consts_const_mock.NEXENT_POSTGRES_PASSWORD = "test_password"
26+
consts_const_mock.POSTGRES_DB = "test_db"
27+
consts_const_mock.POSTGRES_PORT = 5432
28+
consts_mock.const = consts_const_mock
29+
sys.modules['consts'] = consts_mock
30+
sys.modules['consts.const'] = consts_const_mock
1931

2032
# Patch storage factory and MinIO config validation to avoid errors during initialization
2133
# These patches must be started before any imports that use MinioClient

test/backend/test_summary_formatting.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,24 @@
77
import os
88
from unittest.mock import MagicMock, patch
99

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
1628

1729
# Patch storage factory and MinIO config validation to avoid errors during initialization
1830
# These patches must be started before any imports that use MinioClient

0 commit comments

Comments
 (0)