Fix fudai diagnostics and redpacket guard
This commit is contained in:
1 parent
cb74a23e81
commit
28709d2d97
11 files changed
+245
-4
No files matched your search
@@ -5,6 +5,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -21,6 +22,7 @@ from douyin.handlers.screenshot_manager import (
|
||||
get_ocr_dir,
|
||||
reset_async_save_counters,
|
||||
)
|
||||
from douyin.handlers.screenshot_manager.cleanup import cleanup_debug_captures
|
||||
|
||||
|
||||
# ============================================================
|
||||
@@ -143,6 +145,26 @@ class TestEnsureDirs:
|
||||
ensure_debug_captures_dir()
|
||||
ensure_debug_captures_dir()
|
||||
|
||||
def test_cleanup_keeps_today_debug_captures_when_file_limit_exceeded(
|
||||
self, tmp_path, monkeypatch
|
||||
):
|
||||
base_dir = tmp_path / "debug_captures"
|
||||
today_dir = base_dir / datetime.now().strftime("%Y-%m-%d")
|
||||
today_dir.mkdir(parents=True)
|
||||
for index in range(3):
|
||||
(today_dir / f"capture_{index}.png").write_bytes(b"png")
|
||||
|
||||
monkeypatch.setattr(
|
||||
"douyin.handlers.screenshot_manager.cleanup.get_debug_captures_base_dir",
|
||||
lambda: str(base_dir),
|
||||
)
|
||||
|
||||
deleted = cleanup_debug_captures(keep_days=999, max_files=1)
|
||||
|
||||
assert deleted == 0
|
||||
assert today_dir.exists()
|
||||
assert len(list(today_dir.glob("*.png"))) == 3
|
||||
|
||||
|
||||
# ============================================================
|
||||
# _common.py — 异步计数器
|
||||
|
||||
Reference in new issue
Block a user