Update tests/test_utils_elog.py
Run CI Tests / test (push) Successful in 1m24s

This commit is contained in:
2025-08-06 20:48:17 +02:00
parent 10bda457eb
commit 06cf68aeae
+10 -15
View File
@@ -22,10 +22,8 @@ def test_get_default_elog_instance_with_direct_password_and_real_check():
assert hasattr(elog_instance, "post")
# Perform a real GET request to confirm it's accessible with this password
session = elog_instance.session # The elog instance should have an HTTP session
r = session.get(url)
r = requests.get(url, auth=(user, password))
assert r.status_code == 200
assert "demo" in r.text.lower()
@patch("slic.utils.elog.getpass")
@patch("slic.utils.elog.Path.home")
@@ -43,10 +41,8 @@ def test_get_default_elog_instance_asks_password_and_opens(mock_home, mock_getpa
assert hasattr(elog_instance, "post")
# Try a real GET to verify access works
session = elog_instance.session
r = session.get(url)
assert r.status_code == 200
assert "demo" in r.text.lower()
r = requests.get(url, auth=(user, password))
assert r.status_code == 200
@patch("slic.utils.elog.getuser")
@@ -74,9 +70,8 @@ def test_get_default_elog_with_path_home(mock_home, mock_getuser):
assert hasattr(elog_instance, "post")
# Try a real GET request
r = elog_instance.session.get(url)
r = requests.get(url, auth=(user, password))
assert r.status_code == 200
assert "demo" in r.text.lower()
# Cleanup
pw_file.unlink()
@@ -87,21 +82,21 @@ def test_post():
elog = get_test_elog()
title = "AUTHOR_OVERRIDE_TEST"
text = "This entry should use the custom author"
message = "This is a message"
author = "robot"
resp = elog.post(Title=title, Text=text, Author=author)
resp = elog.post(message, Title=title, Author=author)
assert resp is not None
url = f"http://localhost:8080/demo/{resp}"
html = requests.get(url).text
assert title in html, "Title 2 not found"
assert text in html, "Text 2 not found"
assert author in html, f"Custom author '{custom_author}' not found"
assert title in html, "Title not found"
assert text in html, "Message not found"
assert author in html, f"Author not found"
@patch("your_module.elog_wrapper.Screenshot")
@patch("slic.utils.elog.Screenshot")
def test_screenshot(mock_screenshot_class):
# Create fake screenshot file
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp: