From 470f78c144c6e7c54d264f8518d92ab4cca94d08 Mon Sep 17 00:00:00 2001 From: Corban-Lee Jones Date: Thu, 31 Oct 2024 13:11:14 +0000 Subject: [PATCH] write small test --- src/tests.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/tests.py diff --git a/src/tests.py b/src/tests.py new file mode 100644 index 0000000..504ca34 --- /dev/null +++ b/src/tests.py @@ -0,0 +1,34 @@ + +import re + + +def test_content_filters(): + from models import ContentFilter, MatchingAlgorithm + + content_filter = ContentFilter( + id=0, + server_id=0, + name="Test Filter", + matching_pattern="postcode lottery", + matching_algorithm=MatchingAlgorithm.LITERAL, + is_insensitive=True, + is_whitelist=False + ) + + entry = { + "title": "This is the Title of the test Entry", + "description": "This is the description for the postcode lottery" + } + + # Should match 'Test' in entry title with the pattern + assert content_filter.matches(entry) == True + + print("success") + + +def main(): + test_content_filters() + +if __name__ == "__main__": + main() + \ No newline at end of file