def test_postgres_password_as_callable(): def gen_password(): return "Foo" backend = PostgresBackend("postgres://:password@localhost/database", password=gen_password) kwargs = backend._get_connection_kwargs() assert kwargs == {"password": gen_password} assert kwargs["password"]() == "Foo"
async def test_postgres_pool_size_connect(): for url in DATABASE_URLS: if DatabaseURL(url).dialect != "postgresql": continue backend = PostgresBackend(url + "?min_size=1&max_size=20") await backend.connect() await backend.disconnect()
def test_postgres_no_extra_options(): backend = PostgresBackend("postgres://localhost/database") kwargs = backend._get_connection_kwargs() assert kwargs == {}
def test_postgres_explicit_ssl(): backend = PostgresBackend("postgres://localhost/database", ssl=True) kwargs = backend._get_connection_kwargs() assert kwargs == {"ssl": True}
def test_postgres_ssl(): backend = PostgresBackend("postgres://localhost/database?ssl=true") kwargs = backend._get_connection_kwargs() assert kwargs == {"ssl": True}
def test_postgres_explicit_pool_size(): backend = PostgresBackend("postgres://localhost/database", min_size=1, max_size=20) kwargs = backend._get_connection_kwargs() assert kwargs == {"min_size": 1, "max_size": 20}