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
501bbff
commit 5af2f56
Showing
3 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
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
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
32 changes: 32 additions & 0 deletions
32
tests/unit_tests/resource_manager/test_llama_vector_store_factory.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,32 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
|
||
from llama_index.vector_stores import PineconeVectorStore, RedisVectorStore | ||
|
||
from superagi.resource_manager.llama_vector_store_factory import LlamaVectorStoreFactory | ||
from superagi.types.vector_store_types import VectorStoreType | ||
|
||
|
||
def test_llama_vector_store_factory(): | ||
# Mocking method arguments | ||
vector_store_name = VectorStoreType.PINECONE | ||
index_name = "test_index_name" | ||
factory = LlamaVectorStoreFactory(vector_store_name, index_name) | ||
|
||
# Test case for VectorStoreType.PINECONE | ||
with patch.object(PineconeVectorStore, "__init__", return_value=None): | ||
vector_store = factory.get_vector_store() | ||
assert isinstance(vector_store, PineconeVectorStore) | ||
|
||
# Test case for VectorStoreType.REDIS | ||
factory.vector_store_name = VectorStoreType.REDIS | ||
with patch.object(RedisVectorStore, "__init__", return_value=None), \ | ||
patch('superagi.config.config.get_config', return_value=None): | ||
vector_store = factory.get_vector_store() | ||
assert isinstance(vector_store, RedisVectorStore) | ||
|
||
# Test case for unknown VectorStoreType | ||
factory.vector_store_name = "unknown" | ||
with pytest.raises(ValueError) as exc_info: | ||
factory.get_vector_store() | ||
assert str(exc_info.value) == "unknown vector store is not supported yet." |