huanghuoguoguo
bb55cd7ba9
test: tighten phase 1 coverage contracts
2026-05-16 10:30:17 +08:00
huanghuoguoguo
1a3c73bc05
test(quality): fix fake tests and add missing coverage
...
P0 fixes:
- telemetry: rewrite fake tests with real behavior verification (25 tests)
- config: delete copied-source tests, use proper imports (2 deleted)
- persistence: fix try-except pass to verify specific errors
P1 fixes:
- pipeline: add real FixedWindowAlgo tests instead of mocks (12 tests)
- provider: add SessionManager and ToolManager tests (25 tests)
- storage: add S3StorageProvider tests with moto mock (16 tests)
- plugin: add handler action tests for setting inheritance (15 tests)
- rag: add file storage and ZIP processing tests (21 tests)
- vector: add VDB filter conversion tests (30 tests)
P2 fixes:
- pipeline/msgtrun: strengthen assertions for exact message count
- api: add response structure validation in integration tests
New test files:
- provider/test_session_manager.py
- provider/test_tool_manager.py
- storage/test_s3storage.py
- plugin/test_handler_actions.py
- rag/test_file_storage.py
- vector/test_vdb_filter_conversion.py
Source code bugs documented:
- provider: TokenManager.next_token() ZeroDivisionError
- telemetry: send_tasks class variable shared state
- command: empty command IndexError, unused parameters
- utils: funcschema KeyError
- entity: vector.py independent declarative_base
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-16 10:13:15 +08:00
huanghuoguoguo
af58c34c26
test(integration): add embed and monitoring endpoint tests
...
Add integration tests for embed widget and monitoring API endpoints:
- test_embed.py: 15 tests for widget.js, logo, turnstile, messages, reset, feedback
- test_monitoring.py: 15 tests for overview, messages, llm-calls, sessions, errors, export
Coverage improvements:
- embed.py: 17% → 56%
- monitoring.py: 17% → 93%
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-16 10:13:15 +08:00
huanghuoguoguo
12c9d02145
test(integration): add knowledge, bots, and model endpoints tests
...
- Add test_knowledge.py (10 tests) covering knowledge base management
- CRUD operations on /api/v1/knowledge/bases
- Files management endpoints
- Retrieve endpoint with validation
- Coverage: knowledge/base.py 26% → 91%
- Add test_bots.py (9 tests) covering bot management
- CRUD operations on /api/v1/platform/bots
- Logs endpoint
- Send message endpoint with validation
- Coverage: platform/bots.py 24% → 87%
- Extend test_providers.py (+4 tests) for embedding/rerank models
- Embedding models CRUD
- Rerank models CRUD
- Coverage: provider/models.py 29% → 60%
Total integration tests: 53 (smoke 12 + pipelines 10 + providers 14 + knowledge 10 + bots 9)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-16 10:13:15 +08:00
huanghuoguoguo
871c4525ca
test(integration): add API controller integration tests
...
- Add test_pipelines.py (10 tests) covering pipelines CRUD operations
- GET/POST/PUT/DELETE on /api/v1/pipelines
- Extensions endpoint
- Metadata endpoint
- Coverage: pipelines controller 27% → 80%
- Add test_providers.py (10 tests) covering provider/model management
- Provider CRUD with model counts
- LLM model CRUD
- Coverage: providers controller 23% → 81%, models 29% → 45%
Tests use Quart TestClient with mocked services for real HTTP behavior
without external dependencies.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-16 10:13:15 +08:00
huanghuoguoguo
9e1ff7f85c
feat(test): add PostgreSQL migration slow integration tests (G-003)
...
- Add tests/integration/persistence/test_migrations_postgres.py
- All tests marked with @pytest.mark.slow
- Tests skip when TEST_POSTGRES_URL is not set (no local PostgreSQL)
- Database isolation via clean_tables and clean_alembic_version fixtures
- Update CI workflow to use pytest instead of inline Python script
- Remove TODO(G-003) comment
- Update tests/README.md with PostgreSQL test documentation
Covered scenarios:
- Baseline stamp sets revision
- Upgrade from baseline to head
- Upgrade idempotent
- Get current on unstamped DB returns None
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-16 10:12:48 +08:00
huanghuoguoguo
91e99e2f46
feat(test): add developer quality gate consolidation (G-007)
...
- Add scripts/test-integration-fast.sh for fast integration tests
- Add scripts/test-coverage.sh with 12% baseline threshold
- Update Makefile with test-integration-fast, test-coverage, test-all-local
- Update CI workflow with integration and coverage jobs
- Add smoke marker to pytest.ini
- Update tests/README.md with quality gate layers documentation
- Add tests/integration/pipeline/ for pipeline stage-chain tests
Quality gate layers:
- Quick: ruff + unit + smoke (~2 min)
- Fast Integration: SQLite/API/Pipeline (~3 min)
- Coverage: 12% threshold gate (~8 min)
- Full Local: all three combined
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-16 10:12:48 +08:00
huanghuoguoguo
59871c3118
refactor(test): consolidate FakeApp and add sys.modules isolation utility
...
- Extract tests/utils/import_isolation.py with isolated_sys_modules context manager
- Extend tests/factories/app.py FakeApp with handler-specific attributes
- Refactor test_chat_handler.py to use centralized FakeApp and cached imports
- Refactor test_command_handler.py with mock_execute_factory fixture
- Refactor test_smoke.py to move import-time sys.modules manipulation into fixture
- Add SQLite migration integration tests (G-002)
- Add HTTP API smoke integration tests (G-005)
- Update CI workflow to call pytest for SQLite migrations (G-004)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-16 10:12:48 +08:00