Skip to content

Commit 48f25fc

Browse files
committed
Add Azure DB for Postgres to PG integration tests
1 parent 3126472 commit 48f25fc

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

python/tests/integration/memory/vector_stores/postgres/test_postgres_int.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
import pytest_asyncio
1111
from pydantic import BaseModel
1212

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
1317
from semantic_kernel.connectors.memory.postgres import PostgresSettings, PostgresStore
1418
from semantic_kernel.data import (
1519
DistanceFunction,
@@ -40,8 +44,8 @@
4044
connection_params_present = False
4145

4246
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",
4549
)
4650

4751

@@ -85,15 +89,33 @@ def DataModelPandas(record) -> tuple:
8589
return definition, df
8690

8791

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+
90111
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)
93117
except MemoryConnectorConnectionException:
94-
pytest.skip("Postgres connection not available")
95-
yield None
96-
return
118+
pytest.skip(f"{store_type} connection not available")
97119

98120

99121
@asynccontextmanager

0 commit comments

Comments
 (0)