Skip to content

Commit

Permalink
test: add load and clean txt file test
Browse files Browse the repository at this point in the history
  • Loading branch information
mastrolube committed Mar 9, 2024
1 parent 1559c8a commit 6fad04c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/test_load_txt.py
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions test/txt/txt_empty.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@





6 changes: 6 additions & 0 deletions test/txt/txt_ok.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

Hello, test_user! How are you today?
Hello everyone!

Goodbye, test_user! Have a great day!

0 comments on commit 6fad04c

Please sign in to comment.