From 4aadbd0407f6b93dddfb2581a6ea41620c8040d3 Mon Sep 17 00:00:00 2001
From: 9qeklajc
Date: Sun, 23 Aug 2026 11:19:41 +0200
Subject: [PATCH] clean up
---
.../test_reserved_balance_negative.py | 30 +++++++++----------
.../test_streaming_billing_finalization.py | 2 +-
ui/components/temporary-balances.tsx | 16 ++++++----
3 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/tests/integration/test_reserved_balance_negative.py b/tests/integration/test_reserved_balance_negative.py
index d8e2846e..bf23b0be 100644
--- a/tests/integration/test_reserved_balance_negative.py
+++ b/tests/integration/test_reserved_balance_negative.py
@@ -160,14 +160,14 @@ async def test_revert_with_zero_reserved_balance_repairs_terminally(
result = await revert_pay_for_request(test_key, integration_session, 100)
integration_session.expunge_all()
- test_key = await integration_session.get(ApiKey, unique_key)
- assert test_key is not None
+ updated = await integration_session.get(ApiKey, unique_key)
+ assert updated is not None
assert result is True, "Revert must terminalize the corrupt reservation"
- assert test_key.reserved_balance == 0, (
- f"Reserved balance should remain 0, got: {test_key.reserved_balance}"
+ assert updated.reserved_balance == 0, (
+ f"Reserved balance should remain 0, got: {updated.reserved_balance}"
)
- assert test_key.total_requests == 0
+ assert updated.total_requests == 0
@pytest.mark.asyncio
@@ -203,12 +203,12 @@ async def test_child_corrupt_revert_clamps_zero_request_counts(
assert await revert_pay_for_request(child, integration_session, 500, snapshot)
integration_session.expunge_all()
- parent = await integration_session.get(ApiKey, snapshot.billing_key_hash)
- child = await integration_session.get(ApiKey, snapshot.key_hash)
+ parent_row = await integration_session.get(ApiKey, snapshot.billing_key_hash)
+ child_row = await integration_session.get(ApiKey, snapshot.key_hash)
release = await integration_session.get(ReservationRelease, snapshot.release_id)
- assert parent is not None and child is not None
- assert (parent.total_requests, child.total_requests) == (0, 0)
- assert (parent.reserved_balance, child.reserved_balance) == (500, 0)
+ assert parent_row is not None and child_row is not None
+ assert (parent_row.total_requests, child_row.total_requests) == (0, 0)
+ assert (parent_row.reserved_balance, child_row.reserved_balance) == (500, 0)
assert release is not None and release.status == "released"
@@ -271,14 +271,14 @@ async def test_revert_partial_reserved_balance_repairs_terminally(
result = await revert_pay_for_request(test_key, integration_session, 500)
integration_session.expunge_all()
- test_key = await integration_session.get(ApiKey, unique_key)
- assert test_key is not None
+ updated = await integration_session.get(ApiKey, unique_key)
+ assert updated is not None
assert result is True, "Revert must terminalize the corrupt reservation"
- assert test_key.reserved_balance == 50, (
- f"Reserved balance should stay at 50, got: {test_key.reserved_balance}"
+ assert updated.reserved_balance == 50, (
+ f"Reserved balance should stay at 50, got: {updated.reserved_balance}"
)
- assert test_key.total_requests == 0
+ assert updated.total_requests == 0
@pytest.mark.asyncio
diff --git a/tests/unit/test_streaming_billing_finalization.py b/tests/unit/test_streaming_billing_finalization.py
index 0e7a2ee9..51ab2ccf 100644
--- a/tests/unit/test_streaming_billing_finalization.py
+++ b/tests/unit/test_streaming_billing_finalization.py
@@ -387,7 +387,7 @@ async def test_responses_streaming_duplicate_publishes_zero_settled_cost() -> No
max_cost_for_model=500,
)
chunks = [
- chunk.decode() if isinstance(chunk, bytes) else chunk
+ chunk if isinstance(chunk, str) else bytes(chunk).decode()
async for chunk in response.body_iterator
]
diff --git a/ui/components/temporary-balances.tsx b/ui/components/temporary-balances.tsx
index 5d5f1d14..b0705238 100644
--- a/ui/components/temporary-balances.tsx
+++ b/ui/components/temporary-balances.tsx
@@ -323,7 +323,9 @@ export function TemporaryBalances({
)}
- {formatBalance(balance.balance)} raw ·{' '}
+ {formatBalance(balance.balance)} raw
+
+
{formatBalance(balance.reserved_balance)}{' '}
reserved
@@ -404,11 +406,13 @@ export function TemporaryBalances({
)}
{!isChild && (
-
- {formatBalance(balance.balance)} raw ·{' '}
- {formatBalance(balance.reserved_balance)}{' '}
- reserved
-
+
+
{formatBalance(balance.balance)} raw
+
+ {formatBalance(balance.reserved_balance)}{' '}
+ reserved
+
+
)}