|
| 1 | +# Manual Verification Steps: weather.py |
| 2 | + |
| 3 | +Run these checks after any change to `weather.py` to confirm the CLI still |
| 4 | +works end to end. All commands are run from inside `weather_app/` with an |
| 5 | +active internet connection (the app calls the live Open-Meteo API). |
| 6 | + |
| 7 | +## 1. Default table (all cities, current conditions) |
| 8 | + |
| 9 | +``` |
| 10 | +python weather.py |
| 11 | +``` |
| 12 | + |
| 13 | +Expect: a table with one row per city (Helsinki, Espoo, Tampere, Vantaa, |
| 14 | +Oulu, Turku, Jyväskylä, Lahti) showing temp, feels-like, humidity, wind |
| 15 | +speed/direction, and condition. "Jyväskylä" must render correctly, not as |
| 16 | +mojibake (e.g. `Jyv?skyl?`). |
| 17 | + |
| 18 | +## 2. Single city, current conditions |
| 19 | + |
| 20 | +``` |
| 21 | +python weather.py Tampere |
| 22 | +python weather.py tampere |
| 23 | +``` |
| 24 | + |
| 25 | +Expect: both commands (case-insensitive) print the same detailed block |
| 26 | +(condition, temperature, feels like, humidity, wind, precipitation, |
| 27 | +observed-at timestamp) for Tampere. |
| 28 | + |
| 29 | +## 3. Unknown city |
| 30 | + |
| 31 | +``` |
| 32 | +python weather.py NotACity |
| 33 | +echo $? |
| 34 | +``` |
| 35 | + |
| 36 | +Expect: an error message listing the 8 valid city names, printed to |
| 37 | +stderr, and a non-zero exit code (1). |
| 38 | + |
| 39 | +## 4. 7-day forecast |
| 40 | + |
| 41 | +``` |
| 42 | +python weather.py -f |
| 43 | +python weather.py Helsinki --forecast |
| 44 | +``` |
| 45 | + |
| 46 | +Expect: `-f` alone prints a 7-day forecast block for every city in turn |
| 47 | +(date, condition, high/low, precipitation, max wind). `Helsinki --forecast` |
| 48 | +prints just Helsinki's block. Columns should stay aligned even when the |
| 49 | +condition text is long (e.g. "Slight rain showers"). |
| 50 | + |
| 51 | +## 5. Units flag |
| 52 | + |
| 53 | +``` |
| 54 | +python weather.py -u fahrenheit |
| 55 | +python weather.py Helsinki -u fahrenheit |
| 56 | +python weather.py Helsinki -f -u fahrenheit |
| 57 | +python weather.py -u kelvin |
| 58 | +``` |
| 59 | + |
| 60 | +Expect: the first three print Fahrenheit values (suffixed `F`) in the |
| 61 | +table, single-city, and forecast modes respectively, with sensible values |
| 62 | +(e.g. ~50-60F for a Finnish autumn day, not obviously wrong). The last |
| 63 | +command should reject `kelvin` with an argparse usage/error message and |
| 64 | +exit code 2, since only `celsius` and `fahrenheit` are valid choices. |
| 65 | + |
| 66 | +## 6. Network failure handling |
| 67 | + |
| 68 | +Simulate an unreachable API by temporarily pointing the script at a bad |
| 69 | +host, e.g.: |
| 70 | + |
| 71 | +``` |
| 72 | +python -c " |
| 73 | +import weather |
| 74 | +weather.API_URL = 'https://nonexistent.invalid.example/v1/forecast' |
| 75 | +weather.print_table(weather.CITIES) |
| 76 | +" |
| 77 | +``` |
| 78 | + |
| 79 | +Expect: one error line per city (not a raw traceback), and the script |
| 80 | +does not crash. |
| 81 | + |
| 82 | +## 7. Readme accuracy |
| 83 | + |
| 84 | +Re-read `readme.txt` after any CLI flag change and confirm every documented |
| 85 | +command still matches the actual `argparse` options in `weather.py` |
| 86 | +(currently: optional `city` positional, `-f`/`--forecast`, |
| 87 | +`-u`/`--units {celsius,fahrenheit}`). |
0 commit comments