From ec1e25db168561e1bceeebf070e82cca49fd853f Mon Sep 17 00:00:00 2001 From: ThoreOlthoff Date: Tue, 10 Sep 2024 09:25:59 +0200 Subject: [PATCH] edited tests --- mailcom/test/test_inout.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mailcom/test/test_inout.py b/mailcom/test/test_inout.py index 727c94f..e21d6ed 100644 --- a/mailcom/test/test_inout.py +++ b/mailcom/test/test_inout.py @@ -1,9 +1,10 @@ -from mailcom.inout import list_of_files, get_text, get_html_text +from mailcom import inout import pytest from pathlib import Path from importlib import resources pkg = resources.files("mailcom") +io = inout.InoutHandler() FILE_PATH = Path(pkg / "test" / "data" / "Bonjour Agathe.eml") TEXT_REF = "J'espère que tu vas bien!" @@ -11,15 +12,15 @@ def test_list_of_files_found(tmp_path): p = tmp_path / "test.eml" p.write_text("test") - assert len(list_of_files(tmp_path)) != 0 + assert len(io.list_of_files(tmp_path)) != 0 def test_list_of_files_empty(tmp_path): with pytest.raises(ValueError): - list_of_files(tmp_path) + io.list_of_files(tmp_path) def test_list_of_files_dir_not_existing(): with pytest.raises(OSError): - list_of_files("nonexistingDir") + io.list_of_files("nonexistingDir") def test_list_of_files_correct_format(tmp_path): p = tmp_path / "test.eml" @@ -28,29 +29,29 @@ def test_list_of_files_correct_format(tmp_path): p.write_text("test2") p = tmp_path / "test3.xml" p.write_text("test3") - assert tmp_path / "test3.xml" not in list_of_files(tmp_path) + assert tmp_path / "test3.xml" not in io.list_of_files(tmp_path) def test_get_text(tmp_path): p = tmp_path / "test.eml" p.write_text("test") - assert get_text(p) == 'test' - text = get_text(FILE_PATH) + assert io.get_text(p) == 'test' + text = io.get_text(FILE_PATH) print(text[0:25]) assert text[0:25] == TEXT_REF def test_get_text_err(): with pytest.raises(OSError): - list_of_files("nonexistingDir") + io.list_of_files("nonexistingDir") def test_get_html_text(): html = """Test""" - assert get_html_text(html) == 'Test' + assert io.get_html_text(html) == 'Test' def test_get_html_text_noHtml(): noHtml = """Test""" - assert get_html_text(noHtml) == 'Test' + assert io.get_html_text(noHtml) == 'Test' def test_get_text_no_file(tmp_path): p = tmp_path / "test.eml" with pytest.raises(OSError): - get_text(p) \ No newline at end of file + io.get_text(p) \ No newline at end of file