Test improvement - improving notification error network test

pull/1184/head
dgtlmoon 2 years ago committed by GitHub
parent fc94c57d7f
commit 69662ff91c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,23 +11,23 @@ def test_check_notification_error_handling(client, live_server):
set_original_response() set_original_response()
# Give the endpoint time to spin up # Give the endpoint time to spin up
time.sleep(3) time.sleep(2)
# use a different URL so that it doesnt interfere with the actual check until we are ready # Set a URL and fetch it, then set a notification URL which is going to give errors
test_url = url_for('test_endpoint', _external=True) test_url = url_for('test_endpoint', _external=True)
res = client.post( res = client.post(
url_for("form_quick_watch_add"), url_for("form_quick_watch_add"),
data={"url": "https://changedetection.io/CHANGELOG.txt", "tag": ''}, data={"url": test_url, "tag": ''},
follow_redirects=True follow_redirects=True
) )
assert b"Watch added" in res.data assert b"Watch added" in res.data
time.sleep(10) time.sleep(2)
set_modified_response()
# Check we capture the failure, we can just use trigger_check = y here
res = client.post( res = client.post(
url_for("edit_page", uuid="first"), url_for("edit_page", uuid="first"),
data={"notification_urls": "jsons://broken-url.changedetection.io/test", data={"notification_urls": "jsons://broken-url-xxxxxxxx123/test",
"notification_title": "xxx", "notification_title": "xxx",
"notification_body": "xxxxx", "notification_body": "xxxxx",
"notification_format": "Text", "notification_format": "Text",
@ -36,15 +36,14 @@ def test_check_notification_error_handling(client, live_server):
"title": "", "title": "",
"headers": "", "headers": "",
"time_between_check-minutes": "180", "time_between_check-minutes": "180",
"fetch_backend": "html_requests", "fetch_backend": "html_requests"},
"trigger_check": "y"},
follow_redirects=True follow_redirects=True
) )
assert b"Updated watch." in res.data assert b"Updated watch." in res.data
found=False found=False
for i in range(1, 10): for i in range(1, 10):
time.sleep(1)
logging.debug("Fetching watch overview....") logging.debug("Fetching watch overview....")
res = client.get( res = client.get(
url_for("index")) url_for("index"))
@ -53,6 +52,7 @@ def test_check_notification_error_handling(client, live_server):
found=True found=True
break break
time.sleep(1)
assert found assert found
@ -60,7 +60,7 @@ def test_check_notification_error_handling(client, live_server):
# The error should show in the notification logs # The error should show in the notification logs
res = client.get( res = client.get(
url_for("notification_logs")) url_for("notification_logs"))
assert bytes("Name or service not known".encode('utf-8')) in res.data found_name_resolution_error = b"Temporary failure in name resolution" in res.data or b"Name or service not known" in res.data
assert found_name_resolution_error
# And it should be listed on the watch overview client.get(url_for("form_delete", uuid="all"), follow_redirects=True)

Loading…
Cancel
Save