8.4 just test-system

Build it yourself. Read the tutorial is the other way to read this part.

This walk goes through rahuldave/cheesecracker on GitHub. This part starts from the code at 19813cf32d08, partway through step-08. The code before this part

This part does not start where the part before it ends, because the walk skips some changes. This command puts the files that this part starts from in place of yours. Run it, and then go on:

git fetch --quiet --tags --force origin; git restore --source step-07 --staged -- :/ && git restore --source 19813cf32d08 --staged --worktree -- :/

If you start at this part, make your clone as Get the project says, and then run this command. It puts in your clone the files that this part starts from. A file that the project deleted before this part stays, so delete it if git check lists it:

git rm -rq --cached --ignore-unmatch -- :/ && git restore --source 19813cf32d08 --staged --worktree -- :/
just setup
just docker-build run
just docker-serve

The whole tutorial then adds the package requests, which lets Python code send HTTP requests, and writes system tests. A system test sends real HTTP requests to the server at port 9000 of this machine. The system tests need a running server, so just test leaves them out, and just docker-serve above starts one. The system tests get a recipe of their own, apart from just check.

8.4 just test-system runs the system tests

The system tests have a recipe of their own, test-system, apart from just test and just check. A missing server fails them, and never stops a commit.

Apply the patch to justfile, from the top of the project:

curl -fsSL https://github.com/rahuldave/cheesecracker/commit/277d54eebce4a1727ed3d8a5c46570ca4a95f75d.diff | git apply --include=justfile

Read the recipe test-system at the end of the justfile.

just test-system -q

pytest prints 5 passed. Then stop the server, and run the system tests again.

just docker-stop
just test-system -q

pytest fails, with 1 passed, 4 errors. Each error says no server at http://localhost:9000: start one with just docker-serve.

Check your files against this move. The command prints nothing when they match, and otherwise shows what differs:

git check 277d54eebce4

If you are stuck, this command puts the files of this move in place of yours. A file that you made yourself stays:

git fetch --quiet --tags --force origin; git restore --source 19813cf32d08 --staged -- :/ && git restore --source step-08 --staged --worktree -- :/

What changed

  • justfile: the recipe test-system. 4 lines added. The file
    • look at uv run pytest tests/system "$@"

The patch to justfile
@@ -82,3 +82,7 @@ docker-serve:
 # Stop the server of just docker-serve, and remove its container
 docker-stop:
     docker stop cheesecracker-run
+
+# Run the system tests against the server at http://localhost:9000. They fail when no server answers there
+test-system *args:
+    uv run pytest tests/system "$@"

This change on GitHub

This part ends at the code at step-08. The code after this part