Testing¶
The offline test suite covers everything in lastfm_monitor.py that can run without network access. Last.fm and Spotify calls are replaced with test doubles.
Running the suite¶
From the repository root:
pyproject.toml puts the repository root first on sys.path, so the tests exercise the working tree rather than an installed copy.
Run the linter the same way CI does:
Build this documentation the way CI does, which fails on a broken link or a missing page:
CI runs all three on every push and pull request, across Python 3.9 through 3.14, and again before anything is published to PyPI.
What is covered¶
The test layout mirrors the surfaces a user touches rather than the module layout. See tests/README.md for the file-by-file map.
Conventions¶
- Keep every test offline. If a code path needs network access, stub it with
monkeypatchrather than skipping the test. - Restore module-level globals you change. Tests share one imported module, so a leaked global affects whatever runs next.
- Never use a real Last.fm API key or shared secret, Spotify app credentials, SMTP password or webhook URL.
A change to the monitoring loop, the Spotify metadata backends or Last.fm data handling is not verified by this suite alone. Exercise it against a real account and say so in the pull request, without usernames or credentials.