fix: require native groups in workspace payload

This commit is contained in:
2026-08-08 13:41:16 +08:00
parent 48c9c651d7
commit 879b9566cb
4 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "shusub2"
version = "0.3.8"
version = "0.3.9"
description = "Aggregated operations TUI for Sub2API"
readme = "README.md"
requires-python = ">=3.11"
+2 -2
View File
@@ -27,7 +27,7 @@ from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
APP_NAME = "shusub2"
FALLBACK_VERSION = "0.3.8"
FALLBACK_VERSION = "0.3.9"
DEFAULT_WORKSPACE_URL = "https://price.tailbeb9ad.ts.net/api/ui-data?view=workspace"
DEFAULT_WORKSPACE_URL_CONFIG_FILE = "~/.config/shusub2/workspace-url"
DEFAULT_API_URL = "http://127.0.0.1:18318/api/tui/accounts"
@@ -681,7 +681,7 @@ def workspace_account_contract_is_valid(rows: list[dict[str, Any]]) -> bool:
if field in row and not isinstance(row.get(field), str):
return False
group_names = row.get("account_group_names")
if group_names is not None and (
if (
not isinstance(group_names, list)
or len(group_names) > 16
or any(not isinstance(name, str) for name in group_names)
+7
View File
@@ -90,6 +90,7 @@ def workspace_payload_fixture() -> dict[str, object]:
},
"account_rate_multiplier": 0.06,
"account_rate_multiplier_cny": 0.003,
"account_group_names": ["GPT", "customer"],
}
],
},
@@ -1007,6 +1008,12 @@ class WorkspaceTests(unittest.TestCase):
with self.assertRaisesRegex(RuntimeError, "account contract"):
mod.fetch_workspace_payload("https://workspace.example.test/data", 3)
missing_native_groups = workspace_payload_fixture()
missing_native_groups["accounts"]["accounts"][0].pop("account_group_names")
with mock.patch.object(mod, "fetch_workspace_response", return_value=(missing_native_groups, "")):
with self.assertRaisesRegex(RuntimeError, "account contract"):
mod.fetch_workspace_payload("https://workspace.example.test/data", 3)
invalid_period = workspace_payload_fixture()
invalid_period["traffic"].pop("ends_at")
with mock.patch.object(mod, "fetch_workspace_response", return_value=(invalid_period, "")):
Generated
+1 -1
View File
@@ -85,7 +85,7 @@ wheels = [
[[package]]
name = "shusub2"
version = "0.3.8"
version = "0.3.9"
source = { editable = "." }
dependencies = [
{ name = "textual" },