Test Infrastructure: Consolidation & Performance Test Stability
Fixed
-
Consolidation Test Failures - Resolved 4 test failures from consolidation suite (Issue #295)
test_configuration_impact: Fixed mock configuration objects to return proper quality boost settingstest_access_patterns_boost_relevance: Fixed floating-point comparison tolerance in quality score assertionstest_old_access_identification: Corrected quality score threshold triggering (0.8 ≥ 0.7 now works correctly)- Root cause: Mock objects returned None for nested attributes, causing NoneType errors
- Solution: Used MagicMock for full configuration hierarchy and adjusted assertion tolerances
-
Performance Test Failure - Fixed background sync status field mismatch
test_background_sync_with_mock: Corrected field namequeue_size→pending_operations- Root cause: Test used old field name from earlier API version
- Solution: Updated field name to match current HybridStorage implementation
-
Hybrid Storage Async/Await - Fixed TypeErrors in cleanup methods
- Added None-checks before calling close() on sqlite_storage and cloudflare_storage
- Added exception handling in close() methods to prevent TypeErrors during teardown
- Enhanced async method detection using asyncio.iscoroutinefunction()
- Impact: Prevents TypeErrors when storage backends are None during test teardown
-
HTTP API Test Authentication - Disabled authentication in test fixtures
- Removed authentication middleware from test client configuration
- Ensures proper test isolation and prevents auth-related test failures
- Partial fix for Issue #303 (remaining API tests to be addressed separately)
-
pytest-asyncio Configuration - Eliminated deprecation warnings
- Added
asyncio_mode = autoto pytest.ini configuration - Prevents PytestUnraisableExceptionWarning about deprecated @pytest.mark.asyncio usage
- Ensures compatibility with pytest-asyncio 0.23.0+
- Added
Changed
- Test Infrastructure - Improved error handling and cleanup patterns
- Enhanced mock object configuration for nested attribute access
- Improved floating-point comparison tolerance in quality score tests
- Better async/await handling in storage cleanup methods
Quality Metrics
- Code Complexity: 4.96 average (maintained 75% A-grade complexity)
- Security: 0 vulnerabilities (Bandit scan)
- Test Results: 5 previously failing tests now pass
- Performance: No performance regressions
Related
- PR #302: Consolidation and performance test fixes
- Issue #295: Test failure resolution (consolidation + performance suites)
- Issue #303: HTTP API authentication test improvements (partial fix, follow-up needed)
Full Changelog: https://github.com/doobidoo/mcp-memory-service/blob/main/CHANGELOG.md