Merge branch 'main' into cursor/same-day-growth-baseline
This commit is contained in:
commit
9412475473
2 files changed
+60
-4
No files matched your search
@@ -773,6 +773,48 @@ def test_same_day_growth_baselines():
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
def test_system_tasks_sorted_by_started_at_desc():
|
||||
"""最近任务按 started_at 倒序;缺开始时间的排末尾(含进行中无 finished)。"""
|
||||
import json
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
db, q = setup(tmp)
|
||||
try:
|
||||
repo = Repository(db)
|
||||
# 故意打乱写入/键名字母序;finished_at 与 started_at 错开,避免误用完成时间
|
||||
samples = (
|
||||
# name, started_at, finished_at
|
||||
("zzz_old", FIXED_NOW - 300, FIXED_NOW - 10), # 开始最早,完成却很晚
|
||||
("aaa_mid", FIXED_NOW - 100, FIXED_NOW - 90),
|
||||
("mmm_new", FIXED_NOW - 10, None), # 进行中:只有 started
|
||||
("no_time", None, FIXED_NOW), # 缺 started,应末尾
|
||||
)
|
||||
for name, started, finished in samples:
|
||||
payload = {
|
||||
"name": name,
|
||||
"ok": True if finished is not None else True,
|
||||
"error": None,
|
||||
"summary": {},
|
||||
}
|
||||
if started is not None:
|
||||
payload["started_at"] = started
|
||||
if finished is not None:
|
||||
payload["finished_at"] = finished
|
||||
repo.kv_set(f"task:last:{name}", json.dumps(payload))
|
||||
for legacy in ("snapshot", "fans", "discovery"):
|
||||
repo.kv_delete(f"task:last:{legacy}")
|
||||
DASHBOARD_CACHE.clear()
|
||||
system = q.system()
|
||||
assert list(system["tasks"].keys()) == [
|
||||
"mmm_new", "aaa_mid", "zzz_old", "no_time",
|
||||
]
|
||||
overview = q.overview()
|
||||
assert list(overview["tasks"].keys()) == list(system["tasks"].keys())
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
def main_test():
|
||||
test_overview()
|
||||
test_video_listing_filters_and_sorting()
|
||||
@@ -788,6 +830,7 @@ def main_test():
|
||||
test_fans_candidates_system_and_export()
|
||||
test_system_status_uses_completed_date_and_running_flags()
|
||||
test_system_next_runs_follow_last_completion_not_wall_clock()
|
||||
test_system_tasks_sorted_by_started_at_desc()
|
||||
test_growth_auto_falls_back_to_one_day()
|
||||
test_snapshot_recent_next_run_follows_completion()
|
||||
test_overview_adjacent_previous_with_seed_and_dual_fields()
|
||||
|
||||
Reference in new issue
Block a user