test: add 105 new unit tests for untested core functionality

Add comprehensive tests for B-class issues (core functionality untested):

Pipeline:
- test_pool.py: QueryPool ID generation, caching, async context (12 tests)
- test_ratelimit.py: Fixed timing-sensitive test tolerance
- test_pipelinemgr.py: Use real Pydantic StageProcessResult instead of Mock

Utils:
- test_version.py: Version comparison functions (20 tests)
- test_logcache.py: Log page management and retrieval (18 tests)
- test_httpclient.py: HTTP session pool management (10 tests)
- test_proxy.py: Proxy configuration from env and config (10 tests)
- test_image.py: URL parsing and base64 extraction (12 tests)
- test_pkgmgr.py: Pip command generation (8 tests)

Discover:
- test_engine.py: I18nString, Metadata, Component manifest (15 tests)

Test count: 1193 → 1298 (+105 tests)

Note: Some B-class issues cannot be tested due to circular import bugs
filed as GitHub issues #2175 (pipeline) and #2176 (persistence).
This commit is contained in:
huanghuoguoguo
2026-05-11 18:19:54 +08:00
parent 3eaadea3e0
commit 3ba727f0e4
10 changed files with 1390 additions and 20 deletions
+12 -18
View File
@@ -119,30 +119,24 @@ async def test_remove_pipeline(mock_app):
@pytest.mark.asyncio
async def test_runtime_pipeline_execute(mock_app, sample_query):
"""Test runtime pipeline execution"""
"""Test runtime pipeline execution with real Pydantic models."""
pipelinemgr = get_pipelinemgr_module()
stage = get_stage_module()
persistence_pipeline = get_persistence_pipeline_module()
entities = get_entities_module()
# Create mock stage that returns a simple result dict (avoiding Pydantic validation)
mock_result = Mock()
mock_result.result_type = Mock()
mock_result.result_type.value = 'CONTINUE' # Simulate enum value
mock_result.new_query = sample_query
mock_result.user_notice = ''
mock_result.console_notice = ''
mock_result.debug_notice = ''
mock_result.error_notice = ''
# Make it look like ResultType.CONTINUE
from unittest.mock import MagicMock
CONTINUE = MagicMock()
CONTINUE.__eq__ = lambda self, other: True # Always equal for comparison
mock_result.result_type = CONTINUE
# Create result using real Pydantic model (not Mock) to ensure validation
real_result = entities.StageProcessResult(
result_type=entities.ResultType.CONTINUE,
new_query=sample_query,
user_notice='',
console_notice='',
debug_notice='',
error_notice='',
)
mock_stage = Mock(spec=stage.PipelineStage)
mock_stage.process = AsyncMock(return_value=mock_result)
mock_stage.process = AsyncMock(return_value=real_result)
# Create stage container
stage_container = pipelinemgr.StageInstContainer(inst_name='TestStage', inst=mock_stage)