From 3b9d092c0687eb82d8938129ae07c42622ec259c Mon Sep 17 00:00:00 2001 From: yunyaozhou Date: Tue, 9 Jun 2026 16:23:13 +0800 Subject: [PATCH] fix: hide daily quota without limit --- pyproject.toml | 2 +- sub2api_quota_tui.py | 4 +--- tests/test_payload.py | 5 +++++ uv.lock | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1b3e4dd..96dceae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "shusub2" -version = "0.1.4" +version = "0.1.5" description = "Terminal UI for Sub2API account quota and daily usage" readme = "README.md" requires-python = ">=3.11" diff --git a/sub2api_quota_tui.py b/sub2api_quota_tui.py index b7f15f7..0166720 100644 --- a/sub2api_quota_tui.py +++ b/sub2api_quota_tui.py @@ -297,10 +297,8 @@ def window_cell(account: dict[str, Any], window_id: str) -> str: def daily_quota_cell(account: dict[str, Any]) -> str: limit = account.get("daily_quota_limit") used = account.get("daily_quota_used") - if limit is None and used is None: - return "-" if limit is None: - return str(used) + return "-" return f"{used or 0}/{limit}" diff --git a/tests/test_payload.py b/tests/test_payload.py index 103b1db..5c1e82d 100644 --- a/tests/test_payload.py +++ b/tests/test_payload.py @@ -121,6 +121,11 @@ 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_daily_quota_cell_is_dash_without_limit(self) -> None: + mod = load_module() + + self.assertEqual(mod.daily_quota_cell({"daily_quota_used": 0}), "-") + def test_monitor_availability_column_uses_bound_monitor_status(self) -> None: mod = load_module() payload = { diff --git a/uv.lock b/uv.lock index 3320880..9ddd00e 100644 --- a/uv.lock +++ b/uv.lock @@ -85,7 +85,7 @@ wheels = [ [[package]] name = "shusub2" -version = "0.1.4" +version = "0.1.5" source = { editable = "." } dependencies = [ { name = "textual" },