deer-flow/backend/tests/test_support_postgres.py
Guo-Yixin 3182ecb1e4
feat(subagents): preserve RAG evidence in durable batch exports (#6413)
* feat(subagents): preserve RAG evidence in durable batch exports

* docs(subagents): clarify evidence omissions and migration head

* docs(persistence): update the migration chain head

* test(persistence): track the new batch evidence migration head

* test(persistence): verify batch evidence migration on PostgreSQL

* docs(subagents): retain evidence migration compatibility guidance

* fix(subagents): propagate cited evidence forwarding omissions

* fix(tests): adapt batch evidence PostgreSQL CI connection options

* fix(tests): preserve TLS policy in batch evidence migration fixture
2026-10-07 18:37:31 +08:00

36 lines
1.6 KiB
Python

"""Check the real asyncpg dialect's connection contract without a database."""
import pytest
from sqlalchemy.engine import make_url
from support.postgres import asyncpg_test_url
@pytest.mark.parametrize("scheme", ["postgres", "postgresql", "postgresql+asyncpg"])
@pytest.mark.parametrize("sslmode", [None, "disable", "allow", "prefer", "require", "verify-ca", "verify-full"])
def test_asyncpg_test_url_preserves_tls_credentials_and_other_options(scheme, sslmode):
uri = f"{scheme}://user:p%40ss%2Fword@localhost:5432/deerflow_test?target_session_attrs=read-write&channel_binding=prefer"
if sslmode is not None:
uri += f"&sslmode={sslmode}"
url = make_url(asyncpg_test_url(uri))
_args, kwargs = url.get_dialect()().create_connect_args(url)
assert url.drivername == "postgresql+asyncpg"
assert kwargs["password"] == "p@ss/word"
assert kwargs["target_session_attrs"] == "read-write"
assert "sslmode" not in kwargs and "channel_binding" not in kwargs
if sslmode is None:
assert "ssl" not in kwargs
else:
assert kwargs["ssl"] == sslmode
@pytest.mark.parametrize("query", ["ssl=require", "ssl=require&sslmode=require"])
def test_asyncpg_test_url_preserves_explicit_ssl(query):
url = make_url(asyncpg_test_url(f"postgresql://user:password@localhost/test?{query}"))
_args, kwargs = url.get_dialect()().create_connect_args(url)
assert kwargs["ssl"] == "require"
def test_asyncpg_test_url_rejects_conflicting_tls_options():
with pytest.raises(ValueError, match="Conflicting ssl and sslmode"):
asyncpg_test_url("postgresql://user:password@localhost/test?ssl=require&sslmode=disable")