|
10 | 10 | import pytest_asyncio
|
11 | 11 | from pydantic import BaseModel
|
12 | 12 |
|
| 13 | +from semantic_kernel.connectors.memory.azure_db_for_postgres.azure_db_for_postgres_settings import ( |
| 14 | + AzureDBForPostgresSettings, |
| 15 | +) |
| 16 | +from semantic_kernel.connectors.memory.azure_db_for_postgres.azure_db_for_postgres_store import AzureDBForPostgresStore |
13 | 17 | from semantic_kernel.connectors.memory.postgres import PostgresSettings, PostgresStore
|
14 | 18 | from semantic_kernel.data import (
|
15 | 19 | DistanceFunction,
|
|
40 | 44 | connection_params_present = False
|
41 | 45 |
|
42 | 46 | pytestmark = pytest.mark.skipif(
|
43 |
| - not (psycopg_pool_installed or connection_params_present), |
44 |
| - reason="psycopg_pool is not installed" if not psycopg_pool_installed else "No connection parameters provided", |
| 47 | + not psycopg_pool_installed, |
| 48 | + reason="psycopg_pool is not installed", |
45 | 49 | )
|
46 | 50 |
|
47 | 51 |
|
@@ -85,15 +89,33 @@ def DataModelPandas(record) -> tuple:
|
85 | 89 | return definition, df
|
86 | 90 |
|
87 | 91 |
|
88 |
| -@pytest_asyncio.fixture |
89 |
| -async def vector_store() -> AsyncGenerator[PostgresStore, None]: |
| 92 | +@pytest_asyncio.fixture( |
| 93 | + # Parametrize over all Postgres stores. |
| 94 | + params=["PostgresStore", "AzureDBForPostgresStore"] |
| 95 | +) |
| 96 | +async def vector_store(request) -> AsyncGenerator[PostgresStore, None]: |
| 97 | + store_type = request.param |
| 98 | + if store_type == "PostgresStore": |
| 99 | + settings = PostgresSettings.create() |
| 100 | + elif store_type == "AzureDBForPostgresStore": |
| 101 | + settings = AzureDBForPostgresSettings.create() |
| 102 | + |
| 103 | + try: |
| 104 | + connection_params_present = any(settings.get_connection_args().values()) |
| 105 | + except MemoryConnectorInitializationError: |
| 106 | + connection_params_present = False |
| 107 | + |
| 108 | + if not connection_params_present: |
| 109 | + pytest.skip(f"No connection parameters provided for {store_type}") |
| 110 | + |
90 | 111 | try:
|
91 |
| - async with await pg_settings.create_connection_pool() as pool: |
92 |
| - yield PostgresStore(connection_pool=pool) |
| 112 | + async with await settings.create_connection_pool() as pool: |
| 113 | + if store_type == "PostgresStore": |
| 114 | + yield PostgresStore(connection_pool=pool) |
| 115 | + elif store_type == "AzureDBForPostgresStore": |
| 116 | + yield AzureDBForPostgresStore(connection_pool=pool) |
93 | 117 | except MemoryConnectorConnectionException:
|
94 |
| - pytest.skip("Postgres connection not available") |
95 |
| - yield None |
96 |
| - return |
| 118 | + pytest.skip(f"{store_type} connection not available") |
97 | 119 |
|
98 | 120 |
|
99 | 121 | @asynccontextmanager
|
|
0 commit comments