From 3331ccd061caf4a512995f559d17eff285e77ef8 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sun, 9 Jan 2022 11:45:04 +0100 Subject: [PATCH] Add test for low-level network error text handling --- changedetectionio/tests/test_errorhandling.py | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/changedetectionio/tests/test_errorhandling.py b/changedetectionio/tests/test_errorhandling.py index 423316d4..b9a01ac3 100644 --- a/changedetectionio/tests/test_errorhandling.py +++ b/changedetectionio/tests/test_errorhandling.py @@ -35,4 +35,28 @@ def test_error_handler(client, live_server): res = client.get(url_for("index")) assert b'unviewed' not in res.data assert b'Status Code 403' in res.data - assert bytes("just now".encode('utf-8')) in res.data \ No newline at end of file + assert bytes("just now".encode('utf-8')) in res.data + +# Just to be sure error text is properly handled +def test_error_text_handler(client, live_server): + # Give the endpoint time to spin up + time.sleep(1) + + # Add our URL to the import page + res = client.post( + url_for("import_page"), + data={"urls": "https://errorfuldomainthatnevereallyexists12356.com"}, + follow_redirects=True + ) + assert b"1 Imported" in res.data + + # Trigger a check + client.get(url_for("api_watch_checknow"), follow_redirects=True) + + # Give the thread time to pick it up + time.sleep(3) + + res = client.get(url_for("index")) + assert b'Name or service not known' in res.data + assert bytes("just now".encode('utf-8')) in res.data +