Files
ai-workflow-course/modules/04-getting-the-ai-out-of-the-browser/lab/verify.sh
T
justin 3221f7abe8
CI / check (pull_request) Successful in 7s
Use python3 as the canonical command name course-wide (#104)
Most current systems (default Debian/Ubuntu, recent macOS) install Python
only as `python3`, with no bare `python` on PATH, so learners who copied
`python cli.py ...` into their host shell hit "command not found".

Convert host-shell `python <cmd>` -> `python3 <cmd>` across module/lab
READMEs, lab `.py` docstrings & usage strings, blog posts, lab prompt and
instruction files, the M04 verify.sh message, and the M10/M24 lab patches.
Module 01's convention note (and its blog/02 mirror) is rewritten so
`python3` is canonical and `python` is the documented fallback.

Stop-lines respected: Docker image tags (`python:3.12-slim`), `.venv/.../python`
and `...\.venv\Scripts\python.exe` paths, the M20 `"command": "python"`
teaching example and surrounding venv prose, container-internal invocations
(M16/M18 Dockerfiles, M16 README `docker run` examples), and CI-workflow
`run:` steps fed by `actions/setup-python` / `image: python:3.12` are left
as `python` on purpose.

pip was left out of scope: most occurrences are prose or CI/container-internal,
and `pip3` does not fix the PEP 668 externally-managed-environment refusal that
the course already addresses with venvs. The M01 note is worded to stay
consistent with bare `pip` (use whichever pip pairs with your Python).

Build (tools/build_wiki.py) and tools/check.sh both pass.

Closes #104

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GAEzanEoGJT5o1VizQar47
2026-06-23 20:18:04 -04:00

93 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# verify.sh: Module 4 lab check.
#
# Exercises the `delete <index>` command the AI implemented across tasks.py and cli.py.
# It adds three tasks, deletes the middle one by index, and confirms the right task is gone
# and the other two remain. This is a behavior check on the multi-file change; it does not
# care HOW the AI implemented it, only that `delete` works end to end.
#
# Copy this into your tasks-app project directory, then run it from there:
# cp ~/ai-workflow-course/modules/04-getting-the-ai-out-of-the-browser/lab/verify.sh .
# bash verify.sh
#
# (It self-locates cli.py, so it also still works if you run it in place as `bash lab/verify.sh`.)
# It saves and restores your real tasks.json, so your actual task list is left untouched.
set -euo pipefail
# Find the project root: the directory containing cli.py. Works whether you run this from the
# project root or from the lab/ subfolder.
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$here/cli.py" ]; then
root="$here"
elif [ -f "$here/../cli.py" ]; then
root="$(cd "$here/.." && pwd)"
else
root="$(pwd)"
fi
if [ ! -f "$root/cli.py" ]; then
echo "FAIL: couldn't find cli.py. Run this from your tasks-app project directory." >&2
exit 1
fi
# Pick a Python interpreter.
if command -v python3 >/dev/null 2>&1; then
PY=python3
elif command -v python >/dev/null 2>&1; then
PY=python
else
echo "FAIL: no python found on PATH." >&2
exit 1
fi
cd "$root"
# Preserve any real task state, and always restore it on exit (even on failure).
state="tasks.json"
backup=""
if [ -f "$state" ]; then
backup="$(mktemp)"
cp "$state" "$backup"
fi
cleanup() {
if [ -n "$backup" ]; then
mv "$backup" "$state"
else
rm -f "$state"
fi
}
trap cleanup EXIT
# Start from an empty list.
rm -f "$state"
echo "Running delete-command check with: $PY"
"$PY" cli.py add "alpha" >/dev/null
"$PY" cli.py add "beta" >/dev/null
"$PY" cli.py add "gamma" >/dev/null
# Delete the middle task (index 1 = "beta").
if ! "$PY" cli.py delete 1 >/dev/null 2>&1; then
echo "FAIL: 'python3 cli.py delete 1' errored. Is the delete command wired up in cli.py?" >&2
exit 1
fi
out="$("$PY" cli.py list)"
ok=1
echo "$out" | grep -q "beta" && { echo "FAIL: 'beta' should have been deleted but is still listed." >&2; ok=0; }
echo "$out" | grep -q "alpha" || { echo "FAIL: 'alpha' should still be present but is missing." >&2; ok=0; }
echo "$out" | grep -q "gamma" || { echo "FAIL: 'gamma' should still be present but is missing." >&2; ok=0; }
if [ "$ok" -ne 1 ]; then
echo "--- current list ---" >&2
echo "$out" >&2
exit 1
fi
echo "PASS: delete removed the right task; alpha and gamma remain."
echo "The multi-file change works. Review it with 'git diff', then commit."