fix(fulfillment): 修正自动选号候选池

This commit is contained in:
yml
2026-11-18 12:16:20 +08:00
parent 27da489b79
commit 79da819384
3 changed files with 106 additions and 19 deletions
+44
View File
@@ -304,6 +304,50 @@ class TestAccountSelection(_Base):
assert detail["task"]["executionStatus"] == "allocated"
self.refresh_mock.assert_called()
def test_live_candidates_include_support_accounts_and_prefer_valid_cache(self):
support = User(
username="pool-support",
password_hash="h",
role="support",
is_active=True,
)
self.session.add(support)
self.session.flush()
invalid = Account(
username="old-invalid",
password="p",
email="invalid@example.com",
email_password="ep",
status="invalid",
ck_check_status="invalid",
ck_checked_at=NOW - timedelta(days=2),
cookie="PHPSESSID=invalid",
auto_managed=True,
)
valid = Account(
username="support-valid",
password="p",
email="valid@example.com",
email_password="ep",
status="active",
ck_check_status="valid",
ck_checked_at=NOW - timedelta(days=1),
cookie="PHPSESSID=valid",
elite_opened=True,
points=2000,
auto_managed=True,
assigned_to=support.id,
)
self.session.add_all([invalid, valid])
self.session.commit()
rows = account_selector.live_candidate_accounts(
self.session,
required_points=1680,
)
assert [row.id for row in rows] == [valid.id, invalid.id]
def test_points_short_is_soft_and_does_not_block_allocation(self):
account = self.account("points-short", points=100)
task = self.task()