Make blacklist override whitelist
All checks were successful
Test and build Docker image / docker (push) Successful in 30s

Change filter evaluation so blacklist matches take precedence over whitelist matches. Updated evaluator logic to skip entries when blacklist and whitelist both match, adjusted related branches to reflect the new decision flow, and updated a feeds.py comment to clarify the combined decision. Also updated blacklist/whitelist templates copy to reflect the new precedence and adjusted tests to expect blacklist-wins behavior.
This commit is contained in:
Joakim Hellsén 2026-05-04 22:55:53 +02:00
commit d85bc16904
Signed by: Joakim Hellsén
SSH key fingerprint: SHA256:/9h/CsExpFp+PRhsfA0xznFx2CGfTT5R/kpuFfUgEQk
7 changed files with 24 additions and 34 deletions

View file

@ -188,8 +188,8 @@ def test_regex_should_be_sent() -> None:
assert should_be_sent(reader, first_entry[0]) is False, "Entry should not be sent"
def test_active_whitelist_blocks_non_matching_blacklisted_entry() -> None:
"""An active whitelist should block non-matching entries even if blacklist also matches."""
def test_blacklist_blocks_when_active_whitelist_misses() -> None:
"""A blacklist hit should block when an active whitelist does not match."""
reader: Reader = get_reader()
reader.add_feed(feed_url)
@ -213,10 +213,10 @@ def test_active_whitelist_blocks_non_matching_blacklisted_entry() -> None:
whitelist_values=get_filter_values_from_reader(reader, feed, "whitelist"),
)
assert decision.should_send is False, "Entry should be skipped when whitelist is active but does not match"
assert decision.should_send is False, "Entry should be skipped when blacklist matches"
assert decision.blacklist_match is not None, "Expected a blacklist match"
assert decision.whitelist_match is None, "Expected whitelist to miss"
assert "no whitelist rule matched" in decision.reason
assert "blacklist text match on title" in decision.reason
def test_whitelist_substring_match_on_title() -> None: