Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions python/tests/unit/connectors/memory/test_postgres_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ast
import asyncio
from collections.abc import AsyncGenerator
from collections.abc import AsyncGenerator, Callable
from dataclasses import dataclass
from typing import Annotated, Any
from unittest.mock import AsyncMock, MagicMock, Mock, patch
Expand Down Expand Up @@ -248,12 +248,32 @@ async def test_get_records(vector_store: PostgresStore, mock_cursor: Mock) -> No
"filter, filter_sql, filter_params",
[
(None, "", []),
([], "", []),
("lambda x: x.id == 1", ' WHERE ("id" = %s)', [1]),
(lambda x: x.id == 1, ' WHERE ("id" = %s)', [1]),
(["lambda x: x.id == 1"], ' WHERE ("id" = %s)', [1]),
([lambda x: x.id == 1], ' WHERE ("id" = %s)', [1]),
(
["lambda x: x.id > 0", "lambda x: x.id == 1 or x.id == 2"],
' WHERE ("id" > %s) AND (("id" = %s OR "id" = %s))',
[0, 1, 2],
),
(
[
lambda x: x.id > 0,
lambda x: x.id == 1 or x.id == 2,
],
' WHERE ("id" > %s) AND (("id" = %s OR "id" = %s))',
[0, 1, 2],
),
(
[
"lambda x: x.id > 0",
lambda x: x.id == 1 or x.id == 2,
],
' WHERE ("id" > %s) AND (("id" = %s OR "id" = %s))',
[0, 1, 2],
),
],
)
@pytest.mark.parametrize(
Expand All @@ -274,7 +294,7 @@ async def test_vector_search(
subquery_distance: str | None,
include_vectors: bool,
include_total_count: bool,
filter: str | list[str] | None,
filter: str | Callable | list[str | Callable] | None,
filter_sql: str,
filter_params: list[Any],
) -> None:
Expand Down
Loading