forked from TransformerOptimus/SuperAGI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a780c7
commit 5f7b6f7
Showing
2 changed files
with
30 additions
and
73 deletions.
There are no files selected for viewing
73 changes: 0 additions & 73 deletions
73
tests/unit_tests/resource_manager/test_llama_document_summary.py
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
tests/unit_tests/resource_manager/test_save_document_to_vector_store.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from unittest.mock import patch, Mock | ||
from llama_index import VectorStoreIndex, StorageContext, Document | ||
from superagi.resource_manager.resource_manager import ResourceManager | ||
from superagi.resource_manager.llama_vector_store_factory import LlamaVectorStoreFactory | ||
|
||
|
||
@patch.object(LlamaVectorStoreFactory, 'get_vector_store') | ||
@patch.object(StorageContext, 'from_defaults') | ||
@patch.object(VectorStoreIndex, 'from_documents') | ||
def test_save_document_to_vector_store(mock_vc_from_docs, mock_sc_from_defaults, mock_get_vector_store): | ||
# Prepare test resources | ||
mock_vector_store = Mock() | ||
mock_get_vector_store.return_value = mock_vector_store | ||
mock_sc_from_defaults.return_value = "mock_storage_context" | ||
mock_vc_from_docs.return_value = "mock_index" | ||
|
||
resource_manager = ResourceManager("test_agent_id") | ||
documents = [Document(text="doc1"), Document(text="doc2")] | ||
resource_id = "test_resource_id" | ||
|
||
# Run test method | ||
resource_manager.save_document_to_vector_store(documents, resource_id) | ||
|
||
# Validate calls | ||
mock_get_vector_store.assert_called_once() | ||
mock_sc_from_defaults.assert_called_once_with(vector_store=mock_vector_store) | ||
mock_vc_from_docs.assert_called_once_with(documents, storage_context="mock_storage_context") | ||
|
||
# Add more assertions here if needed, e.g., to check side effects | ||
mock_vector_store.persist.assert_called_once() |