feat: show monitor availability column
This commit is contained in:
@@ -121,6 +121,55 @@ class Sub2APIQuotaTUITests(unittest.TestCase):
|
||||
self.assertEqual(rows[0]["daily_quota_cell"], "96.6/300")
|
||||
self.assertTrue(rows[0]["reset"].endswith("00:00") or rows[0]["reset"] != "-")
|
||||
|
||||
def test_monitor_availability_column_uses_bound_monitor_status(self) -> None:
|
||||
mod = load_module()
|
||||
payload = {
|
||||
"generated_at": "2026-06-09T12:00:00+08:00",
|
||||
"totals": {"total_accounts": 1, "usable_accounts": 1, "today_cost_usd": 1, "today_tokens": 100, "today_requests": 2},
|
||||
"accounts": [
|
||||
{
|
||||
"id": 2,
|
||||
"name": "input 300",
|
||||
"base_url_hash": "input-hash",
|
||||
"routing_group": "fast",
|
||||
"provider": "openai",
|
||||
"kind": "daily_limited",
|
||||
"status": "ok",
|
||||
"account_type": "apikey",
|
||||
"today_cost_usd": 1,
|
||||
"today_tokens": 100,
|
||||
"today_requests": 2,
|
||||
"windows": [],
|
||||
}
|
||||
],
|
||||
}
|
||||
status_payload = {
|
||||
"channel_monitors": {
|
||||
"items": [
|
||||
{
|
||||
"name": "other responses",
|
||||
"base_url_hash": "input-hash",
|
||||
"enabled": True,
|
||||
"latest_status": "operational",
|
||||
"latency_ms": 2606,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
rows = mod.normalize_account_rows(payload)
|
||||
out = io.StringIO()
|
||||
|
||||
with contextlib.redirect_stdout(out):
|
||||
mod.print_once(payload, status_payload=status_payload)
|
||||
|
||||
self.assertEqual(mod.monitor_availability(rows[0], status_payload), "ok")
|
||||
self.assertIn("availability", out.getvalue())
|
||||
self.assertIn(" ok\n", out.getvalue())
|
||||
|
||||
def test_monitor_availability_is_dash_without_bound_monitor(self) -> None:
|
||||
mod = load_module()
|
||||
self.assertEqual(mod.monitor_availability({"name": "alpha"}, {}), "-")
|
||||
|
||||
def test_routing_group_sort_shows_sfast_first(self) -> None:
|
||||
mod = load_module()
|
||||
payload = {
|
||||
|
||||
Reference in New Issue
Block a user