From b638a67fcb455b2f0b3e4b6a362b63abfca2e88d Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 30 Apr 2025 15:55:17 +0200 Subject: [PATCH] Improve test coverage --- changedetectionio/tests/test_conditions.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/changedetectionio/tests/test_conditions.py b/changedetectionio/tests/test_conditions.py index fa827d95..d75ed5b7 100644 --- a/changedetectionio/tests/test_conditions.py +++ b/changedetectionio/tests/test_conditions.py @@ -257,17 +257,17 @@ def test_lev_conditions_plugin(client, live_server, measure_memory_usage): # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) res = client.post( - url_for("imports.import_page"), - data={"urls": test_url}, + url_for("ui.ui_views.form_quick_watch_add"), + data={"url": test_url, "tags": '', 'edit_and_watch_submit_button': 'Edit > Watch'}, follow_redirects=True ) - assert b"1 Imported" in res.data + assert b"Watch added in Paused state, saving will unpause" in res.data uuid = next(iter(live_server.app.config['DATASTORE'].data['watching'])) # Give the thread time to pick it up wait_for_all_checks(client) res = client.post( - url_for("ui.ui_edit.edit_page", uuid=uuid), + url_for("ui.ui_edit.edit_page", uuid=uuid, unpause_on_save=1), data={ "url": test_url, "fetch_backend": "html_requests", @@ -278,14 +278,20 @@ def test_lev_conditions_plugin(client, live_server, measure_memory_usage): }, follow_redirects=True ) - assert b"Updated watch." in res.data - res = client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) - assert b'Queued 1 watch for rechecking.' in res.data + assert b"unpaused" in res.data + wait_for_all_checks(client) res = client.get(url_for("watchlist.index")) assert b'unviewed' not in res.data + # Check the content saved initially, even tho a condition was set - this is the first snapshot so shouldnt be affected by conditions + res = client.get( + url_for("ui.ui_views.preview_page", uuid=uuid), + follow_redirects=True + ) + assert b'Which is across multiple lines' in res.data + ############### Now change it a LITTLE bit... with open("test-datastore/endpoint-content.txt", "w") as f: @@ -323,4 +329,4 @@ def test_lev_conditions_plugin(client, live_server, measure_memory_usage): assert b'Queued 1 watch for rechecking.' in res.data wait_for_all_checks(client) res = client.get(url_for("watchlist.index")) - assert b'unviewed' in res.data \ No newline at end of file + assert b'unviewed' in res.data