Files
yuxuanhui afdc5ca909
Deploy Production / deploy (push) Successful in 1m42s
feat(deploy): 接入生产密钥与数据库迁移
2026-08-05 22:45:57 +08:00

27 lines
910 B
Python

import pytest
from zhixing_server.bootstrap.config import sqlalchemy_database_url
def test_sqlalchemy_url_adds_psycopg_driver_and_preserves_query() -> None:
database_url = (
"postgresql://zhixing-system@1Panel-postgresql-5Fc7:5432/zhixing-system"
"?sslmode=require&connect_timeout=5"
)
assert sqlalchemy_database_url(database_url) == (
"postgresql+psycopg://zhixing-system@1Panel-postgresql-5Fc7:5432/zhixing-system"
"?sslmode=require&connect_timeout=5"
)
def test_sqlalchemy_url_does_not_duplicate_psycopg_driver() -> None:
database_url = "postgresql+psycopg://user@localhost:5432/db?sslmode=disable"
assert sqlalchemy_database_url(database_url) == database_url
def test_sqlalchemy_url_rejects_non_postgresql_scheme() -> None:
with pytest.raises(ValueError, match="postgresql"):
sqlalchemy_database_url("mysql://user@localhost/db")