diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 70465b01..8741e45d 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -452,15 +452,18 @@ def changedetection_app(config=None, datastore_o=None): update_q.put(uuid) if form.trigger_check.data: - n_object = {'watch_url': form.url.data.strip(), - 'notification_urls': form.notification_urls.data, - 'notification_title': form.notification_title.data, - 'notification_body' : form.notification_body.data, - 'notification_format' : form.notification_format.data, - } - notification_q.put(n_object) + if len(form.notification_urls.data): + n_object = {'watch_url': form.url.data.strip(), + 'notification_urls': form.notification_urls.data, + 'notification_title': form.notification_title.data, + 'notification_body': form.notification_body.data, + 'notification_format': form.notification_format.data, + } + notification_q.put(n_object) + flash('Test notification queued.') + else: + flash('No notification URLs set, cannot send test.', 'error') - flash('Notifications queued.') # Diff page [edit] link should go back to diff page if request.args.get("next") and request.args.get("next") == 'diff': @@ -527,15 +530,18 @@ def changedetection_app(config=None, datastore_o=None): datastore.data['settings']['application']['notification_urls'] = form.notification_urls.data datastore.data['settings']['application']['base_url'] = form.base_url.data - if form.trigger_check.data and len(form.notification_urls.data): - n_object = {'watch_url': "Test from changedetection.io!", - 'notification_urls': form.notification_urls.data, - 'notification_title': form.notification_title.data, - 'notification_body': form.notification_body.data, - 'notification_format': form.notification_format.data, - } - notification_q.put(n_object) - flash('Notifications queued.') + if form.trigger_check.data: + if len(form.notification_urls.data): + n_object = {'watch_url': "Test from changedetection.io!", + 'notification_urls': form.notification_urls.data, + 'notification_title': form.notification_title.data, + 'notification_body': form.notification_body.data, + 'notification_format': form.notification_format.data, + } + notification_q.put(n_object) + flash('Test notification queued.') + else: + flash('No notification URLs set, cannot send test.', 'error') if form.password.encrypted_password: datastore.data['settings']['application']['password'] = form.password.encrypted_password diff --git a/changedetectionio/tests/test_notification.py b/changedetectionio/tests/test_notification.py index ca53dc1c..1cf4819c 100644 --- a/changedetectionio/tests/test_notification.py +++ b/changedetectionio/tests/test_notification.py @@ -66,7 +66,7 @@ def test_check_notification(client, live_server): follow_redirects=True ) assert b"Updated watch." in res.data - assert b"Notifications queued" in res.data + assert b"Test notification queued" in res.data # Hit the edit page, be sure that we saved it res = client.get( @@ -136,7 +136,7 @@ def test_check_notification(client, live_server): ) assert b"Settings updated." in res.data # Re #143 - should not see this if we didnt hit the test box - assert b"Notifications queued" not in res.data + assert b"Test notification queued" not in res.data # Trigger a check client.get(url_for("api_watch_checknow"), follow_redirects=True)