diff --git a/tests/test_api.py b/tests/test_api.py index 8da70e5..06dd59e 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -753,6 +753,26 @@ def test_tick_sweeps_files_once_a_day(hub, tmp_path, monkeypatch): assert len(calls) == 2 +def test_tick_sweeps_downloads_once_a_day(hub): + h = hub["hub"] + old = time.time() - 31 * 86400 + + def put_old(name): + d = h.db_path.parent / "downloads" / name + d.mkdir(parents=True) + (d / "a.png").write_bytes(b"x") + os.utime(d / "a.png", (old, old)) + os.utime(d, (old, old)) + return d + + first = put_old("1") + h.tick() + assert not first.exists() and "downloads_at" in h.module_state["jira"] + second = put_old("2") + h.tick() + assert second.exists() # второй тик в те же сутки — без уборки + + def test_tick_sweep_failure_logged_auto_refresh_still_runs(hub, monkeypatch, caplog, add_project): _add_project(hub, add_project) def broken(*args, **kwargs):