Skip to content
Edit this page

Testing

Tests are in tests/, one file per area, using unittest (no pytest). They import the source tree as the mousam package (see the shim at the top of tests/test_overview_rules.py), so they need no install, display or network.

File Covers Needs
test_overview_rules.py the overview rules, merging, announcing plain Python
test_levels.py classify_*, unit conversions plain Python
test_forecast.py nearest hour, rain drops, today's high/low, sun times plain Python
test_locations.py saved-city parsing, time zones plain Python
test_api.py the Open-Meteo, air-quality and geocoding modules plain Python (FakeRequests)
test_weather_store.py WeatherStore fetching and status PyGObject (GLib, GObject; no display)
test_notifications.py OverviewNotifications PyGObject (Gio; no display)

New tests are registered in tests/meson.build, so meson test and CI run them.

Run

for t in tests/test_*.py; do python3 "$t"; done     # no build needed
meson test -C builddir --print-errorlogs             # what CI runs

CI (.github/workflows/checks.yml) installs python3-gi, runs ruff, compileall, then meson test, which also validates the gschema, appdata and desktop file. A separate workflow builds the Flatpak.

Fakes (tests/fakes.py)

Fake Stands in for
FakeRequests the requests module (API tests)
FakeForecastClient the forecast API, through the ForecastClient protocol (WeatherStore(client=…))
FakeSettings the GSettings wrapper, which needs the installed schema

Use fixed clocks and hand-built data, never the real time or Open-Meteo.

What to test

New GTK-free logic (a rule, a classifier, a conversion, a parser) gets a test. Add a case to test_overview_rules.py when you add or change a rule. Logic that needs GTK widgets can't be tested this way, which is a reason to keep decisions in core/ (see Architecture).

Lint

ruff check src tests, settings in ruff.toml (Python 3.12 target; E402 and E701 are ignored). Fix a finding rather than silencing it.