返回 DeepSeek-Reasonix
verify.sh
1 #!/usr/bin/env bash
2 set -e
3 # Fresh bytecode cache: macOS system Python caches centrally (pycache_prefix),
4 # where a same-size same-second edit is invisible; a throwaway prefix defeats it.
5 export PYTHONPYCACHEPREFIX="$(mktemp -d)"
6 find . -name '__pycache__' -type d -prune -exec rm -rf {} +
7 python3 - <<'EOF'
8 import inspect
9
10 import handlers
11 import validation
12
13 for handle, verb in [
14 (handlers.handle_create, "created"),
15 (handlers.handle_update, "updated"),
16 (handlers.handle_delete, "deleted"),
17 ]:
18 assert handle({"id": 7, "kind": "note"}) == ("ok", f"{verb} note 7")
19 assert handle("nope") == ("error", "not a request")
20 assert handle({"kind": "note"}) == ("error", "missing id")
21 assert handle({"id": 0, "kind": "note"}) == ("error", "bad id")
22 assert handle({"id": "7", "kind": "note"}) == ("error", "bad id")
23 assert handle({"id": 7, "kind": "meeting"}) == ("error", "bad kind")
24 assert handle({"id": 7}) == ("error", "bad kind")
25
26 assert callable(validation.validate_request), "validation.validate_request must exist"
27 src = inspect.getsource(handlers)
28 assert src.count("validate_request(") >= 3, "all three handlers must call validate_request"
29 assert src.count("missing id") == 0, "inline validation copies must be gone from handlers.py"
30 EOF
31
31 lines BASH