fed8b2eed7
Backend release / release (push) Waiting to run
Bandit Security Scan / bandit_scan (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / manifest (push) Blocked by required conditions
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / manifest (push) Blocked by required conditions
Python linting / ruff (push) Waiting to run
Run python tests with pytest / Run tests and count coverage (3.12) (push) Waiting to run
React Widget Build / build (push) Waiting to run
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from application.vectorstore.vector_creator import VectorCreator
|
|
|
|
|
|
@pytest.mark.unit
|
|
class TestVectorCreator:
|
|
def test_registered_vectorstores(self):
|
|
assert "faiss" in VectorCreator.vectorstores
|
|
assert "elasticsearch" in VectorCreator.vectorstores
|
|
assert "mongodb" in VectorCreator.vectorstores
|
|
assert "qdrant" in VectorCreator.vectorstores
|
|
assert "milvus" in VectorCreator.vectorstores
|
|
assert "pgvector" in VectorCreator.vectorstores
|
|
|
|
def test_create_vectorstore_invalid_type(self):
|
|
with pytest.raises(ValueError, match="No vectorstore class found for type"):
|
|
VectorCreator.create_vectorstore("nonexistent")
|
|
|
|
def test_create_vectorstore_case_insensitive(self):
|
|
with patch.object(
|
|
VectorCreator.vectorstores["faiss"], "__init__", return_value=None
|
|
) as mock_init:
|
|
mock_init.return_value = None
|
|
VectorCreator.create_vectorstore("FAISS", source_id="test", embeddings_key="key")
|
|
mock_init.assert_called_once_with(source_id="test", embeddings_key="key")
|
|
|
|
def test_create_vectorstore_passes_args(self):
|
|
with patch.object(
|
|
VectorCreator.vectorstores["mongodb"], "__init__", return_value=None
|
|
) as mock_init:
|
|
VectorCreator.create_vectorstore(
|
|
"mongodb", source_id="src1", embeddings_key="ek", database="mydb"
|
|
)
|
|
mock_init.assert_called_once_with(
|
|
source_id="src1", embeddings_key="ek", database="mydb"
|
|
)
|