优化(登录预算与任务): 建议上限封顶2000、错误中文化及补全跳过触发来源
This commit is contained in:
@@ -206,3 +206,72 @@ def test_protected_without_cookie_and_captcha_included_in_protected_backlog(db):
|
||||
|
||||
assert recommendation["basis"]["protected_invalid_backlog"] == 2
|
||||
assert recommendation["recommended"]["relogin_protected_daily_limit"] >= 100
|
||||
|
||||
|
||||
def test_large_inventory_caps_daily_budget_at_2000_and_preserves_priority_order(db):
|
||||
now = datetime.now(UTC)
|
||||
accounts = [
|
||||
*[
|
||||
_account(f"large-valid-ordinary-{i}", ck_check_status="valid", status="active")
|
||||
for i in range(600)
|
||||
],
|
||||
*[
|
||||
_account(
|
||||
f"large-invalid-high-{i}",
|
||||
points=400,
|
||||
ck_check_status="invalid",
|
||||
status="invalid",
|
||||
)
|
||||
for i in range(400)
|
||||
],
|
||||
*[
|
||||
_account(f"large-invalid-ord-{i}", ck_check_status="invalid", status="invalid")
|
||||
for i in range(900)
|
||||
],
|
||||
*[
|
||||
_account(
|
||||
f"large-imported-{i}",
|
||||
cookie="",
|
||||
ck_check_status="",
|
||||
status="imported",
|
||||
)
|
||||
for i in range(1500)
|
||||
],
|
||||
]
|
||||
protected = _account(
|
||||
"large-protected-invalid",
|
||||
ck_check_status="invalid",
|
||||
status="invalid",
|
||||
)
|
||||
accounts.append(protected)
|
||||
db.add_all(accounts)
|
||||
db.flush()
|
||||
db.add(
|
||||
PlatformFulfillmentTask(
|
||||
source_order_id="large-protected-order",
|
||||
source_order_item_id="large-protected-item",
|
||||
sale_mode="presale",
|
||||
account_id=protected.id,
|
||||
binding_status="bound",
|
||||
execution_status="bound",
|
||||
)
|
||||
)
|
||||
db.commit()
|
||||
|
||||
recommendation = recommend_login_budget(db, now=now)
|
||||
recommended = recommendation["recommended"]
|
||||
allocated = (
|
||||
recommended["relogin_protected_daily_limit"]
|
||||
+ recommended["lease_refresh_daily_limit"]
|
||||
+ recommended["relogin_high_value_daily_limit"]
|
||||
+ recommended["relogin_ordinary_daily_limit"]
|
||||
+ recommended["onboarding_daily_limit"]
|
||||
+ recommended["manual_daily_limit"]
|
||||
)
|
||||
|
||||
assert recommended["daily_attempt_limit"] <= 2000
|
||||
assert allocated <= recommended["daily_attempt_limit"]
|
||||
assert recommended["manual_daily_limit"] <= 200
|
||||
assert recommended["relogin_protected_daily_limit"] >= 100
|
||||
assert recommended["relogin_high_value_daily_limit"] > 0
|
||||
assert recommended["relogin_ordinary_daily_limit"] > 0
|
||||
|
||||
Reference in New Issue
Block a user