Make blacklist override whitelist
All checks were successful
Test and build Docker image / docker (push) Successful in 30s
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:
parent
dc17850475
commit
d85bc16904
7 changed files with 24 additions and 34 deletions
|
|
@ -207,8 +207,8 @@ def test_regex_should_be_skipped() -> None:
|
|||
assert entry_should_be_skipped(reader, first_entry[0]) is False, f"Entry should not be skipped: {first_entry[0]}"
|
||||
|
||||
|
||||
def test_whitelist_match_overrides_blacklist_match() -> None:
|
||||
"""A whitelist hit should beat a blacklist hit in the final decision."""
|
||||
def test_blacklist_match_overrides_whitelist_match() -> None:
|
||||
"""A blacklist hit should beat a whitelist hit in the final decision."""
|
||||
reader: Reader = get_reader()
|
||||
|
||||
reader.add_feed(feed_url)
|
||||
|
|
@ -232,10 +232,10 @@ def test_whitelist_match_overrides_blacklist_match() -> None:
|
|||
whitelist_values=get_filter_values_from_reader(reader, feed, "whitelist"),
|
||||
)
|
||||
|
||||
assert decision.should_send is True, "Whitelist match should override blacklist match"
|
||||
assert decision.should_send is False, "Blacklist match should override whitelist match"
|
||||
assert decision.blacklist_match is not None, "Expected a blacklist match"
|
||||
assert decision.whitelist_match is not None, "Expected a whitelist match"
|
||||
assert "whitelist overrides blacklist" in decision.reason
|
||||
assert "blacklist overrides whitelist" in decision.reason
|
||||
|
||||
|
||||
def test_blacklist_substring_match_on_title() -> None:
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ def test_blacklist_preview_does_not_persist_unsaved_rules() -> None:
|
|||
reader.delete_tag(feed_url, "blacklist_title")
|
||||
|
||||
|
||||
def test_whitelist_preview_shows_precedence_over_blacklist() -> None:
|
||||
def test_whitelist_preview_shows_blacklist_precedence() -> None:
|
||||
reader: Reader = ensure_preview_feed_exists()
|
||||
reader.set_tag(feed_url, "blacklist_title", "fvnnnfnfdnfdnfd") # pyright: ignore[reportArgumentType]
|
||||
|
||||
|
|
@ -297,8 +297,8 @@ def test_whitelist_preview_shows_precedence_over_blacklist() -> None:
|
|||
)
|
||||
|
||||
assert response.status_code == 200, f"/whitelist_preview failed: {response.text}"
|
||||
assert "whitelist overrides blacklist" in response.text
|
||||
assert "Sent" in response.text
|
||||
assert "blacklist overrides whitelist" in response.text
|
||||
assert "Skipped" in response.text
|
||||
finally:
|
||||
with contextlib.suppress(Exception):
|
||||
reader.delete_tag(feed_url, "blacklist_title")
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue