From 873897326728a0141cc09100dad0f606d23c3064 Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Wed, 20 Nov 2024 15:38:08 -0800 Subject: [PATCH] docs: vectorstore standard tests (#28241) --- .../how_to/integrations/standard_tests.ipynb | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/docs/docs/contributing/how_to/integrations/standard_tests.ipynb b/docs/docs/contributing/how_to/integrations/standard_tests.ipynb index 032c0777477..45739d7d5d9 100644 --- a/docs/docs/contributing/how_to/integrations/standard_tests.ipynb +++ b/docs/docs/contributing/how_to/integrations/standard_tests.ipynb @@ -380,6 +380,62 @@ " return {\"a\": 2, \"b\": 3}" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "
\n", + " Vector Stores" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# title=\"tests/integration_tests/test_vectorstores_sync.py\"\n", + "\n", + "from typing import AsyncGenerator, Generator\n", + "\n", + "import pytest\n", + "from langchain_core.vectorstores import VectorStore\n", + "from langchain_parrot_link.vectorstores import ParrotVectorStore\n", + "from langchain_standard_tests.integration_tests.vectorstores import (\n", + " AsyncReadWriteTestSuite,\n", + " ReadWriteTestSuite,\n", + ")\n", + "\n", + "\n", + "class TestSync(ReadWriteTestSuite):\n", + " @pytest.fixture()\n", + " def vectorstore(self) -> Generator[VectorStore, None, None]: # type: ignore\n", + " \"\"\"Get an empty vectorstore for unit tests.\"\"\"\n", + " store = ParrotVectorStore()\n", + " # note: store should be EMPTY at this point\n", + " # if you need to delete data, you may do so here\n", + " try:\n", + " yield store\n", + " finally:\n", + " # cleanup operations, or deleting data\n", + " pass\n", + "\n", + "\n", + "class TestAsync(AsyncReadWriteTestSuite):\n", + " @pytest.fixture()\n", + " async def vectorstore(self) -> AsyncGenerator[VectorStore, None]: # type: ignore\n", + " \"\"\"Get an empty vectorstore for unit tests.\"\"\"\n", + " store = ParrotVectorStore()\n", + " # note: store should be EMPTY at this point\n", + " # if you need to delete data, you may do so here\n", + " try:\n", + " yield store\n", + " finally:\n", + " # cleanup operations, or deleting data\n", + " pass" + ] + }, { "cell_type": "markdown", "metadata": {},