feat: 任务可调并发、可批量操作,导航栏可收缩
This commit is contained in:
@@ -588,6 +588,34 @@ async def _pause_holds_the_next_grid(tmp_path: Path):
|
||||
assert job.status == "done"
|
||||
|
||||
|
||||
def test_concurrency_waits_until_resume(tmp_path: Path, monkeypatch):
|
||||
monkeypatch.setattr(job_module, "DATA_DIR", tmp_path / "jobs")
|
||||
manager = JobManager()
|
||||
manager.max_concurrent = 2
|
||||
job = _make_job(manager, None)
|
||||
job.status = "running"
|
||||
job.applied_concurrency = 4
|
||||
|
||||
class Alive:
|
||||
def done(self):
|
||||
return False
|
||||
|
||||
job.task = Alive()
|
||||
try:
|
||||
manager.set_concurrency(job, 8)
|
||||
except NqiError as exc:
|
||||
assert "暂停" in str(exc)
|
||||
else:
|
||||
raise AssertionError("下载中不应直接改并发")
|
||||
manager.pause(job)
|
||||
manager.set_concurrency(job, 12)
|
||||
assert job.concurrency == 12
|
||||
assert job.status == "paused"
|
||||
assert manager.place(job) == "resume"
|
||||
assert job.retune.is_set()
|
||||
assert job.status == "running"
|
||||
|
||||
|
||||
def _make_job(manager: JobManager, output: Path | None) -> DownloadJob:
|
||||
return manager.create(
|
||||
network="NR",
|
||||
|
||||
Reference in New Issue
Block a user