69일차 자료 갱신: flow.py test -v, 개요 그림·데이터 예시, Lab 03 예제 1 지금 결과 (정답본 제외)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
17242dc34a
commit
160967b005
10 files changed
+133
-36
No files matched your search
@@ -9,7 +9,7 @@
|
||||
uv run tools/flow.py push my-work/writer.json my-work/reviewer.json # import + publish (one n8n restart)
|
||||
uv run tools/flow.py off my-reviewer # unpublish by file or webhook path (a role that is down)
|
||||
uv run tools/flow.py call my-notice requests/notice-mail.json
|
||||
uv run tools/flow.py test cases/lab02.json [--repeat 3]
|
||||
uv run tools/flow.py test cases/lab02.json -v [--repeat 3] # -v: show each request and response JSON
|
||||
|
||||
Run it from the day folder (Last3Mon/69). n8n is the day 65 install (~/day65-n8n, Docker project
|
||||
day65-n8n), started from Last3Mon/65/n8n. Environment overrides:
|
||||
@@ -494,6 +494,14 @@ def judge(expect: dict, status: int, payload: object) -> list[str]:
|
||||
return problems
|
||||
|
||||
|
||||
def show_json(label: str, value: object) -> None:
|
||||
"""Print one JSON value under a label, indented below the case line (test -v)."""
|
||||
text = json.dumps(value, ensure_ascii=False, indent=2) if not isinstance(value, str) else value
|
||||
print(f" {label}")
|
||||
for row in text.splitlines():
|
||||
print(f" {row}")
|
||||
|
||||
|
||||
def cmd_test(args: argparse.Namespace) -> int:
|
||||
path = resolve(args.cases)
|
||||
suite = load_json(path)
|
||||
@@ -513,6 +521,9 @@ def cmd_test(args: argparse.Namespace) -> int:
|
||||
mark = OK if not problems else BAD
|
||||
suffix = f" #{run}" if args.repeat > 1 else ""
|
||||
print(f"{mark} {case.get('name', '?')}{suffix} · {seconds:.1f}s" + ("" if not problems else " · " + "; ".join(problems)))
|
||||
if args.verbose:
|
||||
show_json(f"→ request POST /webhook/{case_hook}", body)
|
||||
show_json(f"← response HTTP {status}", payload)
|
||||
results.append({"case": case.get("name"), "webhook": case_hook, "run": run, "passed": not problems, "problems": problems,
|
||||
"seconds": round(seconds, 1), "status": status, "request": body, "response": payload})
|
||||
total = len(results)
|
||||
@@ -597,6 +608,7 @@ def main() -> int:
|
||||
item.add_argument("cases")
|
||||
item.add_argument("--repeat", type=int, default=1, help="run every case N times")
|
||||
item.add_argument("--webhook", help="override the webhook path in the case file")
|
||||
item.add_argument("-v", "--verbose", action="store_true", help="print the request and response JSON of every run")
|
||||
item.set_defaults(run=cmd_test)
|
||||
args = parser.parse_args()
|
||||
return args.run(args)
|
||||
|
||||
Reference in new issue
Block a user