mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
fix: pre-existing test issues blocking CI on non-Windows platforms
test_ocr_preflight: mock fitz.open (not builtins.open) + set needs_sanitize=True
- Code uses fitz.open(), not builtins.open() — mock was targeting wrong function
- fitz.open() only called when meta.needs_sanitize is true — mock returned {} which skipped it
- These tests were always broken but CI never ran before v2.1
test_e2e_cli: guard against None stdout in doctor_verdict test on Windows CI
L3 runtime.test.mjs: use platform-agnostic path matching
- path.join produces / on Linux but \\\\ on Windows — test used \\\\ only
This commit is contained in:
parent
c16e3e5198
commit
0d49b5d285
3 changed files with 11 additions and 8 deletions
|
|
@ -36,7 +36,7 @@ describe('resolvePythonExecutable', () => {
|
|||
});
|
||||
|
||||
it('returns venv path when .venv/Scripts/python.exe exists', () => {
|
||||
const d = mockDeps((p) => p.includes('.venv\\Scripts\\python.exe'));
|
||||
const d = mockDeps((p) => p.includes('.venv') && p.includes('python.exe'));
|
||||
const r = resolvePythonExecutable('/vault', {}, d.fs, d.execFileSync);
|
||||
expect(r.path).toContain('.venv');
|
||||
expect(r.source).toBe('auto-detected');
|
||||
|
|
|
|||
|
|
@ -98,7 +98,10 @@ class TestCliDoctor:
|
|||
def test_doctor_outputs_verdict(self, test_vault: Path) -> None:
|
||||
"""Doctor output contains [OK], [WARN], or [FAIL] verdict."""
|
||||
result = _run(["doctor"], test_vault)
|
||||
assert any(tag in result.stdout for tag in ["[OK]", "[WARN]", "[FAIL]"])
|
||||
stdout = result.stdout or ""
|
||||
assert any(tag in stdout for tag in ["[OK]", "[WARN]", "[FAIL]"]), (
|
||||
f"No verdict in doctor output. stdout={stdout[:200]} stderr={(result.stderr or '')[:200]}"
|
||||
)
|
||||
|
||||
|
||||
class TestCliDeepReading:
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class TestOcrPreflight:
|
|||
),
|
||||
patch(
|
||||
"paperforge.worker.ocr.ensure_ocr_meta",
|
||||
return_value={},
|
||||
return_value={"needs_sanitize": True},
|
||||
),
|
||||
patch("paperforge.worker.ocr.write_json") as mock_write,
|
||||
patch("paperforge.worker.sync.run_selection_sync"),
|
||||
|
|
@ -124,7 +124,7 @@ class TestOcrPreflight:
|
|||
),
|
||||
patch(
|
||||
"paperforge.worker.ocr.ensure_ocr_meta",
|
||||
return_value={},
|
||||
return_value={"needs_sanitize": True},
|
||||
),
|
||||
patch("paperforge.worker.ocr.write_json") as mock_write,
|
||||
patch("paperforge.worker.sync.run_selection_sync"),
|
||||
|
|
@ -184,10 +184,10 @@ class TestOcrPreflight:
|
|||
),
|
||||
patch(
|
||||
"paperforge.worker.ocr.ensure_ocr_meta",
|
||||
return_value={},
|
||||
return_value={"needs_sanitize": True},
|
||||
),
|
||||
patch("paperforge.worker.ocr.write_json"),
|
||||
patch("builtins.open") as mock_open,
|
||||
patch("paperforge.worker.ocr.fitz.open") as mock_open,
|
||||
patch("paperforge.worker.ocr.requests.post") as mock_post,
|
||||
patch("paperforge.worker.ocr.requests.get") as mock_get,
|
||||
):
|
||||
|
|
@ -257,10 +257,10 @@ class TestOcrPreflight:
|
|||
),
|
||||
patch(
|
||||
"paperforge.worker.ocr.ensure_ocr_meta",
|
||||
return_value={},
|
||||
return_value={"needs_sanitize": True},
|
||||
),
|
||||
patch("paperforge.worker.ocr.write_json"),
|
||||
patch("builtins.open") as mock_open,
|
||||
patch("paperforge.worker.ocr.fitz.open") as mock_open,
|
||||
patch("paperforge.worker.ocr.requests.post") as mock_post,
|
||||
patch("paperforge.worker.ocr.requests.get") as mock_get,
|
||||
):
|
||||
|
|
|
|||
Loading…
Reference in a new issue