From 1cf9186800beecb2964537debbed2f323c12b797 Mon Sep 17 00:00:00 2001 From: tligui_y Date: Fri, 15 Aug 2025 16:16:48 +0200 Subject: [PATCH] Update tests/test_utils_elog.py --- tests/test_utils_elog.py | 58 +++++++++++++--------------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/tests/test_utils_elog.py b/tests/test_utils_elog.py index ad461bc6a..4c7e2ac0a 100644 --- a/tests/test_utils_elog.py +++ b/tests/test_utils_elog.py @@ -25,17 +25,10 @@ def test_get_default_elog_instance_with_direct_password_and_real_check(): message, attributes, attachments = elog.read(msg_id) - print("Texte bruuuut :", message) - - soup = BeautifulSoup(message, 'html.parser') - content = soup.get_text() - - print("Texte brut :", content) - - assert text in content + assert text in message assert attributes.get("Author") == user -''' + def test_get_default_elog_instance_with_wrong_password_and_real_check(): url = "http://localhost:8080/demo" user = "robot" @@ -58,18 +51,19 @@ def test_get_default_elog_instance_asks_password_and_opens(mock_home, mock_getpa elog = Elog("http://localhost:8080/demo", user=user) try: - elog.post(text) + msd_id = elog.post(text) except Exception as e: pytest.fail(f"elog.open() raised an unexpected exception: {e}") - response = requests.get(url) - soup = BeautifulSoup(response.content, 'html.parser') - content = soup.get_text() + try: + msg_id = elog.post(text) + except Exception as e: + pytest.fail(f"elog.open() raised an unexpected exception: {e}") - print("Password failing : ", content) + message, attributes, attachments = elog.read(msg_id) - assert 'This\xa0is\xa0a\xa0message2' in content, "Message not found" - assert 'robot' in content, f"Author not found" + assert text in message + assert attributes.get("Author") == user @patch("slic.utils.elog.getpass") @@ -92,16 +86,14 @@ def test_get_default_elog_with_path_home(mock_home, mock_getuser, mock_getpass): try: elog = Elog("http://localhost:8080/demo") try: - elog.post(text) + msg_id = elog.post(text) except Exception as e: pytest.fail(f"elog.open() raised an unexpected exception: {e}") - response = requests.get(url) - soup = BeautifulSoup(response.content, 'html.parser') - content = soup.get_text() + message, attributes, attachments = elog.read(msg_id) - assert 'This\xa0is\xa0a\xa0message3' in content, "Message not found" - assert 'robot' in content, f"Author not found" + assert text in message + assert attributes.get("Author") == user finally: pw_file.unlink(missing_ok=True) @@ -120,24 +112,12 @@ def test_screenshot(mock_screenshot_class): elog = elog = Elog("http://localhost:8080/demo", user="robot", password="testpassword") test_msg = "SCREENSHOT_INTEGRATION_TEST_MSG_456" - elog.screenshot(message=test_msg) - - url = "http://localhost:8080/demo/5" - response = requests.get(url) - - print("Texte bruuuut :", response.content) - - soup = BeautifulSoup(response.content, 'html.parser') - content = soup.get_text() - - print("Texte brut :", content) + msg_id = elog.screenshot(message=test_msg) filename = os.path.basename(fake_path) + message, attributes, attachments = elog.read(msg_id) - print("FILE NAME : ", filename) + assert text in message + assert filename in [os.path.basename(a) for a in attachments] - assert test_msg in content, "Message not found" - assert filename in content, f"Attachment '{filename}' not found in post HTML" - - os.remove(fake_path) -''' \ No newline at end of file + os.remove(fake_path) \ No newline at end of file