mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-07 07:58:09 +00:00
test(proxy): cover the dry run CLI and PrismaManager wrapper without a database
This commit is contained in:
parent
53d8f0d72e
commit
883cbf259d
2 changed files with 33 additions and 0 deletions
|
|
@ -586,3 +586,19 @@ async def test_a_query_issued_while_the_last_one_finishes_keeps_the_engine_drain
|
|||
await second
|
||||
await asyncio.wait_for(drained, timeout=1)
|
||||
assert engine.queries_finished == 2
|
||||
|
||||
|
||||
def test_migration_dry_run_summary_without_migrations_has_nothing_to_dry_run(unset_database_url):
|
||||
"""`prisma db push` applies no migration files, so the dry run reports that instead of connecting."""
|
||||
from litellm.proxy.db.prisma_client import PrismaManager
|
||||
|
||||
assert PrismaManager.migration_dry_run_summary(use_migrate=False) == (
|
||||
True,
|
||||
"The schema is pushed rather than migrated, there is nothing to dry-run.",
|
||||
)
|
||||
|
||||
|
||||
def test_migration_dry_run_summary_needs_database_url(unset_database_url):
|
||||
from litellm.proxy.db.prisma_client import PrismaManager
|
||||
|
||||
assert PrismaManager.migration_dry_run_summary(use_migrate=True) == (False, "DATABASE_URL is not set.")
|
||||
|
|
|
|||
|
|
@ -4073,3 +4073,20 @@ def test_granian_flag_notices_are_json_records_in_json_mode(
|
|||
"LiteLLM: --ciphers is not applied when using --run_granian.",
|
||||
]
|
||||
assert {record["level"] for record in records} == {"INFO"}
|
||||
|
||||
|
||||
def test_migration_data_check_exits_zero_when_there_is_nothing_to_dry_run(monkeypatch, capfd):
|
||||
monkeypatch.setenv("DATABASE_URL", "postgresql://user:pass@db.example/litellm")
|
||||
|
||||
assert ProxyInitializationHelpers.run_migration_data_check(use_migrate=False) == 0
|
||||
|
||||
out, err = capfd.readouterr()
|
||||
assert out == "LiteLLM Proxy: The schema is pushed rather than migrated, there is nothing to dry-run.\n"
|
||||
assert err == ""
|
||||
|
||||
|
||||
def test_migration_data_check_requires_database_url(monkeypatch):
|
||||
monkeypatch.delenv("DATABASE_URL", raising=False)
|
||||
|
||||
with pytest.raises(click.UsageError, match="requires DATABASE_URL"):
|
||||
ProxyInitializationHelpers.run_migration_data_check(use_migrate=True)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue