From 7d395d2001fae5fe276f76681815494d528a4559 Mon Sep 17 00:00:00 2001 From: Corban-Lee Jones Date: Fri, 15 Nov 2024 23:47:31 +0000 Subject: [PATCH] tests for other filter cases & a duplicate case --- src/tests/test_content.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/tests/test_content.py b/src/tests/test_content.py index 918aaf3..38ed614 100644 --- a/src/tests/test_content.py +++ b/src/tests/test_content.py @@ -1,3 +1,5 @@ +from dataclasses import replace + import pytest from models import MatchingAlgorithm, ContentFilter, Content @@ -38,14 +40,28 @@ def content_filter() -> ContentFilter: def test_content_filter_any(content: Content, content_filter: ContentFilter): content_filter.matching_pattern = "france twenty report grass lately" content_filter.matching_algorithm = MatchingAlgorithm.ANY - assert content_filter.matches(content) is True + assert content_filter.matches(content) def test_content_filter_all(content: Content, content_filter: ContentFilter): - content_filter.matching_pattern = "week petrol risen" + content_filter.matching_pattern = "week petrol risen since" content_filter.matching_algorithm = MatchingAlgorithm.ALL - assert content_filter.matches(content) is True + assert content_filter.matches(content) + +def test_content_filter_literal(content: Content, content_filter: ContentFilter): + content_filter.matching_pattern = "this week in the papers" + content_filter.matching_algorithm = MatchingAlgorithm.LITERAL + assert content_filter.matches(content) def test_content_filter_regex(content: Content, content_filter: ContentFilter): content_filter.matching_pattern = r"\b(The Papers|weekly quiz)\b" content_filter.matching_algorithm = MatchingAlgorithm.REGEX - assert content_filter.matches(content) is True + assert content_filter.matches(content) + +# def test_content_filter_fuzzy(content: Content, content_filter: ContentFilter): +# content_filter.matching_algorithm = "this week in the papers" +# content_filter.matching_algorithm = MatchingAlgorithm.FUZZY +# assert content_filter.matches(content) + +def test_content_duplicates(content: Content): + copy_of_content = replace(content) + assert content.is_duplicate(copy_of_content)