From cd7df86f54105aff167fc74ed0e6ca707fef5ecb Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 5 Oct 2021 14:33:57 +0200 Subject: [PATCH] Re #242 - app was treating notification field defaults as the field value (#244) --- changedetectionio/__init__.py | 6 ++---- changedetectionio/tests/test_notification.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 0faf874d..6f21beac 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -89,8 +89,7 @@ def populate_form_from_watch(form, watch): if i[0] != '_': p = getattr(form, i) if hasattr(p, 'data') and i in watch: - if not p.data: - setattr(p, "data", watch[i]) + setattr(p, "data", watch[i]) # We use the whole watch object from the store/JSON so we can see if there's some related status in terms of a thread @@ -440,9 +439,8 @@ def changedetection_app(config=None, datastore_o=None): if len(datastore.data['watching'][uuid]['history']): update_obj['previous_md5'] = get_current_checksum_include_ignore_text(uuid=uuid) - datastore.data['watching'][uuid].update(update_obj) - datastore.needs_write = True + flash("Updated watch.") # Queue the watch for immediate recheck diff --git a/changedetectionio/tests/test_notification.py b/changedetectionio/tests/test_notification.py index 2feb36da..9488dc93 100644 --- a/changedetectionio/tests/test_notification.py +++ b/changedetectionio/tests/test_notification.py @@ -14,14 +14,16 @@ def test_check_notification(client, live_server): # Give the endpoint time to spin up time.sleep(3) + # re #242 - when you edited an existing new entry, it would not correctly show the notification settings + # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) res = client.post( - url_for("import_page"), - data={"urls": test_url}, + url_for("api_watch_add"), + data={"url": test_url, "tag": ''}, follow_redirects=True ) - assert b"1 Imported" in res.data + assert b"Watch added" in res.data # Give the thread time to pick up the first version time.sleep(3) @@ -61,6 +63,10 @@ def test_check_notification(client, live_server): url_for("edit_page", uuid="first")) assert bytes(notification_url.encode('utf-8')) in res.data + # Re #242 - wasnt saving? + assert bytes("New ChangeDetection.io Notification".encode('utf-8')) in res.data + + # Because we hit 'send test notification on save' time.sleep(3)