test: cover saving notification settings, the Telegram poller and Send test - #72
Merged
Merged
Conversation
…d test The rest of notifications.py's zero-coverage functions. The one that matters: save_settings treats a None secret as "keep what is stored", because the settings form never round-trips a real token back to the server. If that ever broke, every unrelated checkbox change would silently wipe the bot token and alerts would just stop — no error, nothing on screen. Asserted in both directions: None keeps the stored value, a real value replaces it AND is written encrypted (the plaintext must not appear in the config, and it must decrypt back). Also: thresholds clamp to their bounds rather than storing whatever was posted, and junk in a numeric field is ignored instead of overwriting a good value; the Telegram poller returns None for a malformed or empty token without building a URL; and Send test explains what is missing — five cases, each naming the field — rather than failing mute. update_config is stubbed throughout, so the real data/config.json is never written by these. Verified: the file's bytes are unchanged across a run. (Its mtime does move, but that predates this change — the suite already rewrote it byte-identically at HEAD.) Mutation-verified: making a None token overwrite fails 1, storing the secret in the clear fails 1, dropping the threshold clamp fails 1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | ✅ +0.38% coverage variation (-1.00%) |
| Diff coverage | ✅ ∅ diff coverage |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (0b52813) 11965 5823 48.67% Head commit (d73721b) 11965 (+0) 5869 (+46) 49.05% (+0.38%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#72) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The rest of
notifications.py's zero-coverage functions.The one that matters
save_settingstreats aNonesecret as "keep what's stored", because the settings form never round-trips a real token back to the server. If that ever broke, every unrelated checkbox change would silently wipe the bot token — and alerts would just stop, with no error and nothing on screen.Asserted both directions:
Nonekeeps the stored value, a real value replaces it and is written encrypted (plaintext must not appear in the config, and it must decrypt back).Also covered
Nonefor a malformed or empty token without building a URLOn safety
update_configis stubbed throughout, so the realdata/config.jsonis never written by these. Verified: the file's bytes are unchanged across a run.Its mtime does move, but that predates this change — I checked, and the suite already rewrote it byte-identically at HEAD. Not introduced here, and harmless, but worth knowing.
Mutation-verified:
unit 854 → 867 · lint clean.
🤖 Generated with Claude Code