From 7285913b343362b49dcaed6982912c379970c282 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Fri, 7 Jun 2024 08:20:24 +0200 Subject: [PATCH] removing some delays --- .../tests/restock/test_restock.py | 1 - .../tests/test_add_replace_remove_filter.py | 2 -- changedetectionio/tests/test_auth.py | 9 ++++---- .../test_automatic_follow_ldjson_price.py | 2 -- changedetectionio/tests/test_backup.py | 3 --- .../tests/test_block_while_text_present.py | 2 -- changedetectionio/tests/test_clone.py | 3 --- changedetectionio/tests/test_css_selector.py | 22 ++++++------------- .../tests/test_element_removal.py | 7 ++---- changedetectionio/tests/test_encoding.py | 6 ----- changedetectionio/tests/test_errorhandling.py | 4 ---- .../tests/test_filter_exist_changes.py | 2 -- .../tests/test_filter_failure_notification.py | 3 +-- .../tests/test_history_consistency.py | 2 -- .../tests/test_ignorehyperlinks.py | 3 --- changedetectionio/tests/util.py | 3 +-- 16 files changed, 15 insertions(+), 59 deletions(-) diff --git a/changedetectionio/tests/restock/test_restock.py b/changedetectionio/tests/restock/test_restock.py index 30528cd1..a0b9d14e 100644 --- a/changedetectionio/tests/restock/test_restock.py +++ b/changedetectionio/tests/restock/test_restock.py @@ -53,7 +53,6 @@ def test_restock_detection(client, live_server): set_original_response() #assert os.getenv('PLAYWRIGHT_DRIVER_URL'), "Needs PLAYWRIGHT_DRIVER_URL set for this test" - time.sleep(1) live_server_setup(live_server) ##################### notification_url = url_for('test_notification_endpoint', _external=True).replace('http://localhost', 'http://changedet').replace('http', 'json') diff --git a/changedetectionio/tests/test_add_replace_remove_filter.py b/changedetectionio/tests/test_add_replace_remove_filter.py index f64d877b..4233e8ab 100644 --- a/changedetectionio/tests/test_add_replace_remove_filter.py +++ b/changedetectionio/tests/test_add_replace_remove_filter.py @@ -40,8 +40,6 @@ def test_setup(client, live_server): def test_check_removed_line_contains_trigger(client, live_server): - # Give the endpoint time to spin up - time.sleep(1) set_original() # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) diff --git a/changedetectionio/tests/test_auth.py b/changedetectionio/tests/test_auth.py index b84f8cf7..578112e1 100644 --- a/changedetectionio/tests/test_auth.py +++ b/changedetectionio/tests/test_auth.py @@ -2,13 +2,12 @@ import time from flask import url_for -from . util import live_server_setup +from .util import live_server_setup, wait_for_all_checks + def test_basic_auth(client, live_server): live_server_setup(live_server) - # Give the endpoint time to spin up - time.sleep(1) # Add our URL to the import page test_url = url_for('test_basicauth_method', _external=True).replace("//","//myuser:mypass@") @@ -19,7 +18,7 @@ def test_basic_auth(client, live_server): follow_redirects=True ) assert b"1 Imported" in res.data - time.sleep(1) + wait_for_all_checks(client) # Check form validation res = client.post( @@ -29,7 +28,7 @@ def test_basic_auth(client, live_server): ) assert b"Updated watch." in res.data - time.sleep(1) + wait_for_all_checks(client) res = client.get( url_for("preview_page", uuid="first"), follow_redirects=True diff --git a/changedetectionio/tests/test_automatic_follow_ldjson_price.py b/changedetectionio/tests/test_automatic_follow_ldjson_price.py index f0c0d104..7da76962 100644 --- a/changedetectionio/tests/test_automatic_follow_ldjson_price.py +++ b/changedetectionio/tests/test_automatic_follow_ldjson_price.py @@ -104,8 +104,6 @@ def test_check_ldjson_price_autodetect(client, live_server): client.get(url_for('price_data_follower.accept', uuid=uuid, follow_redirects=True)) wait_for_all_checks(client) - # Trigger a check - time.sleep(1) client.get(url_for("form_watch_checknow"), follow_redirects=True) wait_for_all_checks(client) # Offer should be gone diff --git a/changedetectionio/tests/test_backup.py b/changedetectionio/tests/test_backup.py index 9f381755..e237df73 100644 --- a/changedetectionio/tests/test_backup.py +++ b/changedetectionio/tests/test_backup.py @@ -13,9 +13,6 @@ def test_backup(client, live_server): set_original_response() - # Give the endpoint time to spin up - time.sleep(1) - # Add our URL to the import page res = client.post( url_for("import_page"), diff --git a/changedetectionio/tests/test_block_while_text_present.py b/changedetectionio/tests/test_block_while_text_present.py index 2669b52a..25f51ece 100644 --- a/changedetectionio/tests/test_block_while_text_present.py +++ b/changedetectionio/tests/test_block_while_text_present.py @@ -68,8 +68,6 @@ def test_check_block_changedetection_text_NOT_present(client, live_server): set_original_ignore_response() - # Give the endpoint time to spin up - time.sleep(1) # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) diff --git a/changedetectionio/tests/test_clone.py b/changedetectionio/tests/test_clone.py index 7f502be1..86339caa 100644 --- a/changedetectionio/tests/test_clone.py +++ b/changedetectionio/tests/test_clone.py @@ -10,9 +10,6 @@ def test_trigger_functionality(client, live_server): live_server_setup(live_server) - # Give the endpoint time to spin up - time.sleep(1) - # Add our URL to the import page res = client.post( url_for("import_page"), diff --git a/changedetectionio/tests/test_css_selector.py b/changedetectionio/tests/test_css_selector.py index dcc10331..08884876 100644 --- a/changedetectionio/tests/test_css_selector.py +++ b/changedetectionio/tests/test_css_selector.py @@ -77,9 +77,6 @@ def test_check_markup_include_filters_restriction(client, live_server): set_original_response() - # Give the endpoint time to spin up - time.sleep(1) - # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) res = client.post( @@ -89,8 +86,7 @@ def test_check_markup_include_filters_restriction(client, live_server): ) assert b"1 Imported" in res.data - # Give the thread time to pick it up - time.sleep(sleep_time_for_fetch_thread) + wait_for_all_checks(client) # Goto the edit page, add our ignore text # Add our URL to the import page @@ -100,22 +96,22 @@ def test_check_markup_include_filters_restriction(client, live_server): follow_redirects=True ) assert b"Updated watch." in res.data - time.sleep(1) + wait_for_all_checks(client) # Check it saved res = client.get( url_for("edit_page", uuid="first"), ) assert bytes(include_filters.encode('utf-8')) in res.data - # Give the thread time to pick it up - time.sleep(sleep_time_for_fetch_thread) + + wait_for_all_checks(client) # Make a change set_modified_response() # Trigger a check client.get(url_for("form_watch_checknow"), follow_redirects=True) # Give the thread time to pick it up - time.sleep(sleep_time_for_fetch_thread) + wait_for_all_checks(client) # It should have 'unviewed' still # Because it should be looking at only that 'sametext' id @@ -138,8 +134,6 @@ def test_check_multiple_filters(client, live_server): """) - # Give the endpoint time to spin up - time.sleep(1) # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) @@ -149,7 +143,7 @@ def test_check_multiple_filters(client, live_server): follow_redirects=True ) assert b"1 Imported" in res.data - time.sleep(1) + wait_for_all_checks(client) # Goto the edit page, add our ignore text # Add our URL to the import page @@ -164,9 +158,7 @@ def test_check_multiple_filters(client, live_server): ) assert b"Updated watch." in res.data - # Give the thread time to pick it up - time.sleep(sleep_time_for_fetch_thread) - + wait_for_all_checks(client) res = client.get( url_for("preview_page", uuid="first"), follow_redirects=True diff --git a/changedetectionio/tests/test_element_removal.py b/changedetectionio/tests/test_element_removal.py index 3c280d22..30ff37e4 100644 --- a/changedetectionio/tests/test_element_removal.py +++ b/changedetectionio/tests/test_element_removal.py @@ -5,7 +5,7 @@ import time from flask import url_for from ..html_tools import * -from .util import live_server_setup +from .util import live_server_setup, wait_for_all_checks def test_setup(live_server): @@ -111,16 +111,13 @@ def test_element_removal_full(client, live_server): set_original_response() - # Give the endpoint time to spin up - time.sleep(1) - # 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}, follow_redirects=True ) assert b"1 Imported" in res.data - time.sleep(1) + wait_for_all_checks(client) # Goto the edit page, add the filter data # Not sure why \r needs to be added - absent of the #changetext this is not necessary subtractive_selectors_data = "header\r\nfooter\r\nnav\r\n#changetext" diff --git a/changedetectionio/tests/test_encoding.py b/changedetectionio/tests/test_encoding.py index 4b273edf..186f075f 100644 --- a/changedetectionio/tests/test_encoding.py +++ b/changedetectionio/tests/test_encoding.py @@ -27,9 +27,6 @@ def set_html_response(): def test_check_encoding_detection(client, live_server): set_html_response() - # Give the endpoint time to spin up - time.sleep(1) - # Add our URL to the import page test_url = url_for('test_endpoint', content_type="text/html", _external=True) client.post( @@ -56,9 +53,6 @@ def test_check_encoding_detection(client, live_server): def test_check_encoding_detection_missing_content_type_header(client, live_server): set_html_response() - # Give the endpoint time to spin up - time.sleep(1) - # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) client.post( diff --git a/changedetectionio/tests/test_errorhandling.py b/changedetectionio/tests/test_errorhandling.py index d439fee1..9c67fe1f 100644 --- a/changedetectionio/tests/test_errorhandling.py +++ b/changedetectionio/tests/test_errorhandling.py @@ -64,8 +64,6 @@ def test_http_error_handler(client, live_server): # Just to be sure error text is properly handled def test_DNS_errors(client, live_server): - # Give the endpoint time to spin up - time.sleep(1) # Add our URL to the import page res = client.post( @@ -89,8 +87,6 @@ def test_DNS_errors(client, live_server): # Re 1513 def test_low_level_errors_clear_correctly(client, live_server): #live_server_setup(live_server) - # Give the endpoint time to spin up - time.sleep(1) with open("test-datastore/endpoint-content.txt", "w") as f: f.write("
Hello world
") diff --git a/changedetectionio/tests/test_filter_exist_changes.py b/changedetectionio/tests/test_filter_exist_changes.py index e57db579..825d1b45 100644 --- a/changedetectionio/tests/test_filter_exist_changes.py +++ b/changedetectionio/tests/test_filter_exist_changes.py @@ -48,8 +48,6 @@ def test_filter_doesnt_exist_then_exists_should_get_notification(client, live_se live_server_setup(live_server) - # Give the endpoint time to spin up - time.sleep(1) set_response_without_filter() # Add our URL to the import page diff --git a/changedetectionio/tests/test_filter_failure_notification.py b/changedetectionio/tests/test_filter_failure_notification.py index b25931ea..25557f4c 100644 --- a/changedetectionio/tests/test_filter_failure_notification.py +++ b/changedetectionio/tests/test_filter_failure_notification.py @@ -23,8 +23,7 @@ def set_response_with_filter(): def run_filter_test(client, content_filter): - # Give the endpoint time to spin up - time.sleep(1) + wait_for_all_checks(client) # cleanup for the next client.get( url_for("form_delete", uuid="all"), diff --git a/changedetectionio/tests/test_history_consistency.py b/changedetectionio/tests/test_history_consistency.py index a7e46a57..08986b9d 100644 --- a/changedetectionio/tests/test_history_consistency.py +++ b/changedetectionio/tests/test_history_consistency.py @@ -11,8 +11,6 @@ from urllib.parse import urlparse, parse_qs def test_consistent_history(client, live_server): live_server_setup(live_server) - # Give the endpoint time to spin up - time.sleep(1) r = range(1, 50) for one in r: diff --git a/changedetectionio/tests/test_ignorehyperlinks.py b/changedetectionio/tests/test_ignorehyperlinks.py index f917125f..612e7323 100644 --- a/changedetectionio/tests/test_ignorehyperlinks.py +++ b/changedetectionio/tests/test_ignorehyperlinks.py @@ -45,9 +45,6 @@ def test_render_anchor_tag_content_true(client, live_server): render_anchor_tag_content setting is set to true""" sleep_time_for_fetch_thread = 3 - # Give the endpoint time to spin up - time.sleep(1) - # set original html text set_original_ignore_response() diff --git a/changedetectionio/tests/util.py b/changedetectionio/tests/util.py index 186fc736..67b22419 100644 --- a/changedetectionio/tests/util.py +++ b/changedetectionio/tests/util.py @@ -125,12 +125,11 @@ def wait_for_all_checks(client): attempt=0 time.sleep(0.1) while attempt < 60: - time.sleep(1) res = client.get(url_for("index")) if not b'Checking now' in res.data: break logging.getLogger().info("Waiting for watch-list to not say 'Checking now'.. {}".format(attempt)) - + time.sleep(1) attempt += 1 def live_server_setup(live_server):