feat(douyu): 建立账号同步队列与供给库存

This commit is contained in:
yml
2026-11-21 21:48:51 +08:00
parent 1d262cdfd9
commit 3baf15afda
16 changed files with 1158 additions and 33 deletions
+12 -13
View File
@@ -8,6 +8,7 @@ from web.backend.models import (
Account,
AccountCommodityState,
AccountLease,
AccountWorkItem,
AutomationJob,
PlatformFulfillmentTask,
User,
@@ -124,7 +125,7 @@ def test_no_pending_task_means_no_refresh(db):
assert job.build_select_query(db, automation_job, NOW).all() == []
def test_run_does_not_execute_exact_remaining_count(db, monkeypatch):
def test_run_enqueues_stale_accounts_without_external_query(db):
db.add(
PlatformFulfillmentTask(
source_system="order_site",
@@ -148,19 +149,17 @@ def test_run_does_not_execute_exact_remaining_count(db, monkeypatch):
batch_size=10,
concurrency=3,
)
captured: dict[str, object] = {}
result = job.run_account_capability_refresh(db, automation_job)
def fake_run_refresh(_db, _job, accounts, **kwargs):
captured["accounts"] = [row.id for row in accounts]
captured["remaining_count"] = kwargs.get("remaining_count")
return {"scanned": len(accounts)}
monkeypatch.setattr(job, "run_refresh_for_accounts", fake_run_refresh)
job.run_account_capability_refresh(db, automation_job)
assert captured["accounts"] == [stale.id]
assert captured["remaining_count"] is None
work = (
db.query(AccountWorkItem)
.filter_by(account_id=stale.id, work_type="storehome_sync")
.one()
)
assert result["scanned"] == 1
assert result["success"] == 1
assert work.status == "pending"
assert work.priority == 40
def test_default_enabled_job_is_created_enabled(db, monkeypatch):