From d88da3cd88a9a26769a78c0bf2540a4412592878 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Fri, 13 Dec 2024 10:37:30 +0100 Subject: [PATCH] adding test --- changedetectionio/tests/test_notification.py | 56 ++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/changedetectionio/tests/test_notification.py b/changedetectionio/tests/test_notification.py index e47693f3..e43f81f5 100644 --- a/changedetectionio/tests/test_notification.py +++ b/changedetectionio/tests/test_notification.py @@ -442,4 +442,60 @@ def test_global_send_test_notification(client, live_server, measure_memory_usage assert b"Error: You must have atleast one watch configured for 'test notification' to work" in res.data +#2510 +def test_html_color_notifications(client, live_server, measure_memory_usage): + + #live_server_setup(live_server) + set_original_response() + if os.path.isfile("test-datastore/notification.txt"): + os.unlink("test-datastore/notification.txt") + + + test_notification_url = url_for('test_notification_endpoint', _external=True).replace('http://', 'post://')+"?xxx={{ watch_url }}&+custom-header=123" + + + # otherwise other settings would have already existed from previous tests in this file + res = client.post( + url_for("settings_page"), + data={ + "application-fetch_backend": "html_requests", + "application-minutes_between_check": 180, + #"application-notification_body": '{{diff}}', + "application-notification_format": "HTML Color", + "application-notification_urls": test_notification_url, + "application-notification_title": "New ChangeDetection.io Notification - {{ watch_url }}", + }, + follow_redirects=True + ) + assert b'Settings updated' in res.data + + test_url = url_for('test_endpoint', _external=True) + res = client.post( + url_for("form_quick_watch_add"), + data={"url": test_url, "tags": 'nice one'}, + follow_redirects=True + ) + + assert b"Watch added" in res.data + + wait_for_all_checks(client) + + set_modified_response() + + + res = client.get(url_for("form_watch_checknow"), follow_redirects=True) + assert b'1 watches queued for rechecking.' in res.data + + wait_for_all_checks(client) + time.sleep(3) + + with open("test-datastore/notification.txt", 'r') as f: + x = f.read() + assert 'Which is across multiple lines' in x + + + client.get( + url_for("form_delete", uuid="all"), + follow_redirects=True + )