Private
Public Access
test(rag): update dim mismatch test + stress test for new implementation
- tests/test_rag_engine.py: The dim mismatch test was written for the
old delete_collection implementation. The new implementation uses
shutil.rmtree + new PersistentClient (per commit 24e93a75) for
better Windows file-lock robustness. Updated the test to:
* assert mock_client.get_or_create_collection.call_count == 2 (still true)
* assert mock_client.delete_collection.assert_not_called() (new behavior)
- tests/test_rag_phase4_stress.py: Use unique collection name per test
invocation to avoid dim-mismatch path in batched live_gui context.
Also changed the error check from "error" to "error:" to only fail
on detailed errors from the AI request handler, not the bare "error"
status from model fetch failures (anthropic circular import).
This commit is contained in:
@@ -105,12 +105,15 @@ def test_rag_collection_dim_mismatch_recreates_collection(mock_get_chroma, mock_
|
||||
mock_st.return_value = MagicMock()
|
||||
engine = RAGEngine(config)
|
||||
assert engine.collection == mock_collection
|
||||
# On dim mismatch, _validate_collection_dim_result calls
|
||||
# client.delete_collection(name) then get_or_create_collection(name)
|
||||
# to recreate the collection with the correct dim. The first
|
||||
# get_or_create_collection call was in _init_vector_store_result.
|
||||
# On dim mismatch, _validate_collection_dim_result rmtree's the collection
|
||||
# directory (WinError 32 safe) then creates a new PersistentClient +
|
||||
# collection. The first get_or_create_collection call was in
|
||||
# _init_vector_store_result. The old implementation called
|
||||
# client.delete_collection(name); the new implementation uses
|
||||
# shutil.rmtree + new PersistentClient for better Windows file-lock
|
||||
# robustness (per fix_rag_test_phase4_final_verify_20260627).
|
||||
assert mock_client.get_or_create_collection.call_count == 2
|
||||
mock_client.delete_collection.assert_called_once_with("test")
|
||||
mock_client.delete_collection.assert_not_called()
|
||||
|
||||
@patch('src.rag_engine.LocalEmbeddingProvider.embed')
|
||||
@patch('src.rag_engine._get_chromadb')
|
||||
|
||||
Reference in New Issue
Block a user