Files
syops/backend/tests/test_edkb_file_timeout.py
T

32 lines
1.1 KiB
Python

"""Tests for edkb per-file timeout selection."""
from __future__ import annotations
from pathlib import Path
from edkb_system.controller import _file_timeout_sec
def test_excel_skips_spawn_timeout_wrapper(monkeypatch):
monkeypatch.setenv('EDKB_FILE_TIMEOUT_SEC', '180')
assert _file_timeout_sec(Path('report.xlsx')) is None
assert _file_timeout_sec(Path('data.csv')) is None
def test_word_still_uses_word_timeout(monkeypatch):
monkeypatch.setenv('EDKB_FILE_TIMEOUT_SEC', '180')
monkeypatch.setenv('EDKB_WORD_FILE_TIMEOUT_SEC', '420')
assert _file_timeout_sec(Path('manual.docx')) == 420
def test_pdf_uses_dedicated_timeout_for_figure_rich_handbooks(monkeypatch):
monkeypatch.setenv('EDKB_FILE_TIMEOUT_SEC', '300')
monkeypatch.setenv('EDKB_PDF_FILE_TIMEOUT_SEC', '900')
# 断言大型图文手册不会被通用 300 秒时限提前终止。
assert _file_timeout_sec(Path('mechanical-design-handbook.pdf')) == 900
def test_other_formats_use_global_timeout(monkeypatch):
monkeypatch.setenv('EDKB_FILE_TIMEOUT_SEC', '180')
assert _file_timeout_sec(Path('slides.pptx')) == 180