| 1 | #!/usr/bin/env bash |
| 2 | set -e |
| 3 | export PYTHONPYCACHEPREFIX="$(mktemp -d)" |
| 4 | rm -f balances.json rejected.txt |
| 5 | # Exit status is unspecified by the prompt (a non-zero "rejections happened" |
| 6 | # code is defensible); only the written artifacts are graded. |
| 7 | python3 ledger.py || true |
| 8 | python3 - <<'EOF' |
| 9 | import json |
| 10 | |
| 11 | with open("balances.json") as f: |
| 12 | balances = json.load(f) |
| 13 | assert balances == {"ashwick": 5, "korrin": 90, "selby": 30}, balances |
| 14 | assert list(balances) == sorted(balances), "keys must be sorted" |
| 15 | |
| 16 | with open("rejected.txt") as f: |
| 17 | rejected = [line.rstrip("\n") for line in f if line.strip()] |
| 18 | assert rejected == ["withdraw selby 200", "withdraw ashwick 10"], rejected |
| 19 | EOF |
| 20 |