mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-13 08:52:02 +00:00
test(alerts): isolate freshness from pending accounting
This commit is contained in:
parent
6559458af3
commit
afff31bcc9
1 changed files with 2 additions and 8 deletions
|
|
@ -52,21 +52,15 @@ async def test_batch_checkpoints_preserve_rule_revisions_and_incomplete_status(d
|
|||
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
async def test_freshness_timestamps_use_the_real_prisma_parameter_types(db: ManagementDatabase) -> None:
|
||||
repository: Final = UsageAlertHealthRepository.from_prisma(db.prisma)
|
||||
start: Final = datetime.now(timezone.utc).replace(hour=0, minute=0, second=0, microsecond=0) + timedelta(days=2)
|
||||
try:
|
||||
async with _isolated(db) as prisma:
|
||||
repository: Final = UsageAlertHealthRepository.from_prisma(prisma)
|
||||
assert await repository.record("user", start)
|
||||
assert (await repository.coverage("user", start)).hours == 1
|
||||
assert not (await repository.coverage("user", start)).after_grace
|
||||
assert await repository.record("user", start + timedelta(days=1, hours=1))
|
||||
coverage: Final = await repository.coverage("user", start)
|
||||
assert coverage.hours == 1 and coverage.after_grace
|
||||
finally:
|
||||
await db.prisma.writer_db.query_raw(
|
||||
"DELETE FROM \"LiteLLM_UsageAlertFlush\" WHERE source='user' AND hour IN ($1::timestamp,$2::timestamp) RETURNING source",
|
||||
start.replace(tzinfo=None),
|
||||
(start + timedelta(days=1, hours=1)).replace(tzinfo=None),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio(loop_scope="session")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue