-
test: add regression tests for SettingsManager API compatibility (#1878)
发布于
2026-02-01 23:08:37 +00:00 - Fix issue with indexing local files.
This ultimately stems from having two separate
SettingsManagerclasses with slightly different APIs. I think in the future, we should remove the legacy one (inmanager.py), which these changes were made with an eye towards.-
Don't mess with NPM lockfile.
-
test: add regression tests for SettingsManager API compatibility
Add comprehensive tests to prevent regression of issue #1877 where
rag_routes.py imports SettingsManager from the wrong module.Tests added to tests/web/services/test_settings_manager.py:
- TestGetSettingsSnapshot: Tests for get_settings_snapshot() method
- TestGetBoolSettingMethod: Tests for get_bool_setting() method
- TestSettingsManagerApiCompatibility: Verify required methods exist
Tests added to tests/research_library/routes/test_rag_routes.py:
- TestSettingsManagerImportCompatibility: Verify correct import source
- TestBackgroundThreadSettingsManagerUsage: Test thread function usage
Tests marked with xfail will pass once PR #1877 is merged:
- get_settings_snapshot tests (method added by PR #1877)
- source code import check (imports fixed by PR #1877)
- integration tests that run the actual code path
Related: #1877
- test: add comprehensive edge case and thread safety tests
Additional tests for SettingsManager API compatibility:
- TestGetBoolSettingEdgeCases: whitespace handling, mixed case,
None values, empty strings, numeric values - TestGetBoolSettingEnvOverride: environment variable override
behavior with checkbox vs text ui_elements - TestSettingsManagerErrorHandling: DB error fallback, no session
- TestSettingsManagerBackgroundThreadUsage: background thread creation,
concurrent access - TestGetSettingsSnapshotAdvanced: mutation isolation, complex
values, RAG service usage pattern
Total: 27 passed, 16 xfailed (waiting for PR #1877)
- refactor: remove xfail markers and fragile source code test
- Remove all @pytest.mark.xfail decorators since PR now targets djpetti's
hotfix/local-search-error branch which has the get_settings_snapshot method - Remove fragile test_rag_routes_import_source_code_check test that used
AST to examine source code (too brittle as djpetti noted) - Update class docstrings to remove xfail notes
- test: add protocol-based interface tests for SettingsManager
Add comprehensive tests using Python's Protocol (PEP 544) to prevent
regression of issue #1877 where wrong SettingsManager import caused
'object has no attribute' errors.New tests include:
- RagRoutesSettingsProtocol: Defines the contract for rag_routes.py
- Protocol compliance tests with @runtime_checkable
- Import identity test verifying correct class is used
- Method signature tests matching actual usage patterns
- Cross-implementation compatibility documentation
- Examples of using protocol for type checking and mocking
These tests catch wrong imports at test time rather than runtime,
providing better regression protection.
Co-authored-by: Daniel Petti djpetti@gmail.com
下载附件