Add remote browser pages and website sync
Enable managed remote browser custom pages with login autofill and add website sync workflows so external admin surfaces can be handled inside SmartUp. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
from app.services.website_client import normalize_groups
|
||||
|
||||
|
||||
def test_normalize_groups_unwraps_sub2api_paginated_response():
|
||||
groups = normalize_groups({
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"items": [
|
||||
{"id": "codex-free", "name": "codex-free", "rate_multiplier": 1},
|
||||
{"id": "my-plus", "name": "my-plus", "rate_multiplier": "1.5"},
|
||||
{"id": "deepseek", "name": "deepseek"},
|
||||
],
|
||||
"total": 3,
|
||||
"page": 1,
|
||||
},
|
||||
})
|
||||
|
||||
assert [group["id"] for group in groups] == ["codex-free", "my-plus", "deepseek"]
|
||||
assert groups[0]["rate_multiplier"] == "1"
|
||||
assert groups[1]["rate_multiplier"] == "1.5"
|
||||
assert groups[2]["rate_multiplier"] is None
|
||||
|
||||
|
||||
def test_normalize_groups_unwraps_wrapped_list_response():
|
||||
groups = normalize_groups({
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": [
|
||||
{"id": "default", "name": "Default", "rateMultiplier": "2.0"},
|
||||
],
|
||||
})
|
||||
|
||||
assert groups == [{
|
||||
"id": "default",
|
||||
"name": "Default",
|
||||
"rate_multiplier": "2",
|
||||
"raw": {"id": "default", "name": "Default", "rateMultiplier": "2.0"},
|
||||
}]
|
||||
|
||||
|
||||
def test_normalize_groups_unwraps_groups_key_response():
|
||||
groups = normalize_groups({
|
||||
"data": {
|
||||
"groups": [
|
||||
{"group_id": "vip", "group_name": "VIP", "ratio": "0.75"},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
assert groups[0]["id"] == "vip"
|
||||
assert groups[0]["name"] == "VIP"
|
||||
assert groups[0]["rate_multiplier"] == "0.75"
|
||||
|
||||
|
||||
def test_normalize_groups_keeps_string_list_compatibility():
|
||||
groups = normalize_groups(["free", "paid"])
|
||||
|
||||
assert [group["id"] for group in groups] == ["free", "paid"]
|
||||
assert groups[0]["raw"] == {"id": "free", "name": "free"}
|
||||
|
||||
|
||||
def test_normalize_groups_keeps_plain_dict_mapping_compatibility():
|
||||
groups = normalize_groups({
|
||||
"free": {"id": "free", "name": "Free", "rate_multiplier": "1.00"},
|
||||
"paid": {"id": "paid", "name": "Paid"},
|
||||
})
|
||||
|
||||
assert [group["id"] for group in groups] == ["free", "paid"]
|
||||
assert groups[0]["rate_multiplier"] == "1"
|
||||
Reference in New Issue
Block a user