tests for other filter cases & a duplicate case
Some checks failed
Build and Push Docker Image / build (push) Failing after 7m2s
Some checks failed
Build and Push Docker Image / build (push) Failing after 7m2s
This commit is contained in:
parent
b0b02aae9f
commit
7d395d2001
@ -1,3 +1,5 @@
|
|||||||
|
from dataclasses import replace
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from models import MatchingAlgorithm, ContentFilter, Content
|
from models import MatchingAlgorithm, ContentFilter, Content
|
||||||
@ -38,14 +40,28 @@ def content_filter() -> ContentFilter:
|
|||||||
def test_content_filter_any(content: Content, 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_pattern = "france twenty report grass lately"
|
||||||
content_filter.matching_algorithm = MatchingAlgorithm.ANY
|
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):
|
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
|
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):
|
def test_content_filter_regex(content: Content, content_filter: ContentFilter):
|
||||||
content_filter.matching_pattern = r"\b(The Papers|weekly quiz)\b"
|
content_filter.matching_pattern = r"\b(The Papers|weekly quiz)\b"
|
||||||
content_filter.matching_algorithm = MatchingAlgorithm.REGEX
|
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user