From 38954743171f5fa68f125451f69bd1fe01ee2a66 Mon Sep 17 00:00:00 2001 From: Diian-r Date: Thu, 11 May 2023 16:08:16 -0400 Subject: [PATCH] Created tests for the helper functions in summary_mixin.py --- tests/puterbot/test_summary_mixin.py | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tests/puterbot/test_summary_mixin.py diff --git a/tests/puterbot/test_summary_mixin.py b/tests/puterbot/test_summary_mixin.py new file mode 100644 index 000000000..041458a99 --- /dev/null +++ b/tests/puterbot/test_summary_mixin.py @@ -0,0 +1,66 @@ +""" +Tests the 2 helper functions (clean_ascii and compare_text) in summary_mixin.py +""" +from puterbot.strategies.summary_mixin import clean_ascii, compare_text + + +################################################################ +# Clean ASCII tests +################################################################ + + +def test_clean_ascii_empty(): + empty_text = "" + expected = "" + actual = clean_ascii(empty_text) + assert actual == expected + + +def test_clean_ascii_no_symbols_or_stopwords(): + no_symbols = "wow no symbols" + expected = "wow no symbols" + actual = clean_ascii(no_symbols) + assert actual == expected + + +def test_clean_ascii_some_symbols_and_stopwords(): + many_symbols = "wow this! has some... symbols" + expected = "wow has some symbols" + actual = clean_ascii(many_symbols) + assert actual == expected + + +def test_clean_ascii_all_symbols_and_stopwords(): + all_symbols = "&*@#($)#!| ~~ this \\" + expected = "" + actual = clean_ascii(all_symbols) + assert actual == expected + + +################################################################ +# Compare text tests +################################################################ + + +def test_compare_text_empty(): + text1 = "" + text2 = "" + expected = 0 + actual = compare_text(text1, text2) + assert actual == expected + + +def test_compare_text_similar(): + text1 = "I love sunshine so much." + text2 = "I adore the sun." + expected = 50 + actual = compare_text(text1, text2) + assert actual > expected + + +def test_compare_text_not_similar(): + text1 = "I love sunshine so much" + text2 = "Once upon a time, there was a princess." + expected = 50 + actual = compare_text(text1, text2) + assert actual < expected