diff --git a/README.md b/README.md index adbb261..11a31cf 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ python console_view.py 7 The environment ID is the required argument; `environments.json` records the ID of each environment created by `main.py`. The Viron server is expected at the same address as for `main.py` (see [Starting Viron](#starting-viron)). The application uses Viron's `LocationService`, so it needs the `Viron/` submodule and Requests, but not Pygame. -The exit status is `0` once the environment is printed. It is `1`, with a message, if the locations cannot be fetched or there are none, which is also how an ID unknown to Viron shows up, and `2`, with a usage line, if the argument is missing or is not an integer. `--help` or `-h` prints the usage line and exits with status `0` without contacting Viron. +The exit status is `0` once the environment is printed. It is `1`, with a message, if the locations cannot be fetched or there are none, which is also how an ID unknown to Viron shows up, and `2`, with a usage line, if the argument is missing, is not an integer, or is followed by further arguments. `--help` or `-h` prints the usage line and exits with status `0` without contacting Viron. Nothing is created in Viron, no file is written, and no usage is reported. Viron gives every grid the same coordinates, so the grids of an environment with several would be drawn on top of each other; environments created by `main.py` have one. @@ -300,7 +300,8 @@ The GIF at the top was recorded from an unmodified `python main.py 20` run under Usage reporting is on by default: Patchwork sends its name (`patchwork`), its version from `version.txt` and the events `startup` (once per launch) and `environment-created` (when a new environment is created through Viron) to [trace](https://danielstephenson.dev/usage-reporting) -at `https://trace.danielstephenson.dev`, so that it is known which versions are in use. Every +at `https://trace.danielstephenson.dev`, so that it is known which versions are in use. If +`version.txt` is missing, cannot be opened or is empty, `unknown` is sent as the version instead. Every event also carries a random installation ID (the tag `install`) so installations can be counted rather than events; beyond that, nothing about you, your machine, your IP address, the grid size or the environments is sent. The report diff --git a/console_view.py b/console_view.py index dd7f8c1..f030900 100644 --- a/console_view.py +++ b/console_view.py @@ -8,7 +8,8 @@ python console_view.py The exit status is 0 if the environment was printed, 1 if it could not be fetched or has -no locations, and 2 if the argument is missing or is not an integer. +no locations, and 2 if the argument is missing, is not an integer, or is followed by +further arguments. """ import sys diff --git a/tests/test_console_view.py b/tests/test_console_view.py index fcf1076..8f6252d 100644 --- a/tests/test_console_view.py +++ b/tests/test_console_view.py @@ -68,6 +68,15 @@ def test_a_non_integer_argument_prints_the_usage_and_exits_two(self): self.assertEqual(status, 2) self.assertEqual(output, console_view.usage + "\n") + def test_a_further_argument_prints_the_usage_and_exits_two_without_reaching_viron(self): + locationService = fakeLocationService([]) + + status, output = runMain(["console_view.py", "7", "8"], locationService) + + self.assertEqual(status, 2) + self.assertEqual(output, console_view.usage + "\n") + locationService.get_locations_in_environment.assert_not_called() + def test_help_prints_the_usage_and_exits_zero_without_reaching_viron(self): for flag in ("--help", "-h"): with self.subTest(flag=flag), patch.object(console_view, "LocationService") as service: