From 8fe2d2bb8845bd155c8c5728a1711a6fa469c417 Mon Sep 17 00:00:00 2001 From: MikiVL Date: Tue, 5 May 2026 13:19:20 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E9=AA=8C=E8=AF=81=20Python=20stdin/std?= =?UTF-8?q?out=20JSON=20=E9=80=9A=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/python/test_main.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/python/test_main.py diff --git a/tests/python/test_main.py b/tests/python/test_main.py new file mode 100644 index 0000000..df0641a --- /dev/null +++ b/tests/python/test_main.py @@ -0,0 +1,24 @@ +import sys, os, json, subprocess + +PYTHON = sys.executable +MAIN = os.path.join(os.path.dirname(__file__), "../../python/main.py") +FIXTURE = os.path.join(os.path.dirname(__file__), "../fixtures/sample_template.xlsx") + +def _call(payload: dict) -> dict: + proc = subprocess.run( + [PYTHON, MAIN], + input=json.dumps(payload) + "\n", + capture_output=True, + text=True, + timeout=10, + ) + return json.loads(proc.stdout.strip()) + +def test_parse_template_via_stdin(): + result = _call({"action": "parse_template", "file_path": FIXTURE}) + assert "sheets" in result + assert "Sheet1" in result["sheets"] + +def test_unknown_action_returns_error(): + result = _call({"action": "nonexistent"}) + assert "error" in result