From 4d3df98f07f180e6844394108b359e2e4685a8b7 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 16 Oct 2025 13:53:43 +0200 Subject: [PATCH] Fix tests --- changedetectionio/notification_service.py | 3 +++ .../tests/test_filter_failure_notification.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/changedetectionio/notification_service.py b/changedetectionio/notification_service.py index 2f5e3fd44..d5b38fdd2 100644 --- a/changedetectionio/notification_service.py +++ b/changedetectionio/notification_service.py @@ -230,6 +230,7 @@ class NotificationService: n_format = self.datastore.data['settings']['application'].get('notification_format', default_notification_format) filter_list = ", ".join(watch['include_filters']) + # @todo - This could be a markdown template on the disk, apprise will convert the markdown to HTML+Plaintext parts in the email, and then 'markup_text_to_html' is not needed body = f"""Hello, Your configured CSS/xPath filters of '{filter_list}' for {{{{watch_url}}}} did not appear on the page after {threshold} attempts. @@ -276,6 +277,8 @@ Thanks - Your omniscient changedetection.io installation. threshold = self.datastore.data['settings']['application'].get('filter_failure_notification_threshold_attempts') n_format = self.datastore.data['settings']['application'].get('notification_format', default_notification_format).lower() step = step_n + 1 + # @todo - This could be a markdown template on the disk, apprise will convert the markdown to HTML+Plaintext parts in the email, and then 'markup_text_to_html' is not needed + # {{{{ }}}} because this will be Jinja2 {{ }} tokens body = f"""Hello, diff --git a/changedetectionio/tests/test_filter_failure_notification.py b/changedetectionio/tests/test_filter_failure_notification.py index 2871fbdc0..b78f47645 100644 --- a/changedetectionio/tests/test_filter_failure_notification.py +++ b/changedetectionio/tests/test_filter_failure_notification.py @@ -131,9 +131,15 @@ def run_filter_test(client, live_server, content_filter, app_notification_format # Text (or HTML conversion) markup to make the notifications a little nicer should have worked if app_notification_format.startswith('html'): - assert 'a href' in notification - arrived_filter = content_filter.replace('"', '\\"') - assert arrived_filter in notification + # apprise should have used sax-escape (' instead of ", " etc), lets check it worked + + from apprise.conversion import convert_between + from apprise.common import NotifyFormat + escaped_filter = convert_between(NotifyFormat.TEXT, NotifyFormat.HTML, content_filter) + + assert escaped_filter in notification or escaped_filter.replace('"', '"') in notification + assert 'a href="' in notification # Quotes should still be there so the link works + else: assert 'a href' not in notification assert content_filter in notification