diff --git a/test/test_load_txt.py b/test/test_load_txt.py new file mode 100644 index 00000000..c9bcc93c --- /dev/null +++ b/test/test_load_txt.py @@ -0,0 +1,24 @@ +from GramAddict.core.interaction import _load_and_clean_txt_file + + +def test_load_txt_ok(mocker): + mocker.patch("os.path.join", return_value="txt/txt_ok.txt") + message = _load_and_clean_txt_file("test_user", "txt_filename") + assert message is not None + assert message == [ + "Hello, test_user! How are you today?", + "Hello everyone!", + "Goodbye, test_user! Have a great day!", + ] + + +def test_load_txt_empty(mocker): + mocker.patch("os.path.join", return_value="txt/txt_empty.txt") + message = _load_and_clean_txt_file("test_user", "txt_filename") + assert message is None + + +def test_load_txt_not_exists(mocker): + mocker.patch("os.path.join", return_value="txt/txt_not_exists.txt") + message = _load_and_clean_txt_file("test_user", "txt_filename") + assert message is None diff --git a/test/txt/txt_empty.txt b/test/txt/txt_empty.txt new file mode 100644 index 00000000..3f2ff2d6 --- /dev/null +++ b/test/txt/txt_empty.txt @@ -0,0 +1,5 @@ + + + + + diff --git a/test/txt/txt_ok.txt b/test/txt/txt_ok.txt new file mode 100644 index 00000000..7e3585ae --- /dev/null +++ b/test/txt/txt_ok.txt @@ -0,0 +1,6 @@ + +Hello, test_user! How are you today? +Hello everyone! + +Goodbye, test_user! Have a great day! +