diff --git a/changedetectionio/tests/fetchers/test_content.py b/changedetectionio/tests/fetchers/test_content.py index b68e71231..76b78ce82 100644 --- a/changedetectionio/tests/fetchers/test_content.py +++ b/changedetectionio/tests/fetchers/test_content.py @@ -28,8 +28,6 @@ def test_fetch_webdriver_content(client, live_server): ) assert b"1 Imported" in res.data - time.sleep(3) - wait_for_all_checks(client) diff --git a/changedetectionio/tests/proxy_list/test_proxy.py b/changedetectionio/tests/proxy_list/test_proxy.py index 1f4c5ff41..2da09fc0b 100644 --- a/changedetectionio/tests/proxy_list/test_proxy.py +++ b/changedetectionio/tests/proxy_list/test_proxy.py @@ -16,4 +16,4 @@ def test_check_basic_change_detection_functionality(client, live_server): ) assert b"1 Imported" in res.data - time.sleep(3) + wait_for_all_checks(client) diff --git a/changedetectionio/tests/restock/test_restock.py b/changedetectionio/tests/restock/test_restock.py index d00fed10f..77557918e 100644 --- a/changedetectionio/tests/restock/test_restock.py +++ b/changedetectionio/tests/restock/test_restock.py @@ -94,7 +94,7 @@ def test_restock_detection(client, live_server): assert b'not-in-stock' not in res.data # We should have a notification - time.sleep(2) + wait_for_all_checks(client) assert os.path.isfile("test-datastore/notification.txt") os.unlink("test-datastore/notification.txt") diff --git a/changedetectionio/tests/test_access_control.py b/changedetectionio/tests/test_access_control.py index b8063683a..2f6c403d1 100644 --- a/changedetectionio/tests/test_access_control.py +++ b/changedetectionio/tests/test_access_control.py @@ -1,4 +1,4 @@ -from . util import live_server_setup, extract_UUID_from_client +from .util import live_server_setup, extract_UUID_from_client, wait_for_all_checks from flask import url_for import time @@ -19,10 +19,10 @@ def test_check_access_control(app, client, live_server): ) assert b"1 Imported" in res.data - time.sleep(2) + wait_for_all_checks(client) res = client.get(url_for("form_watch_checknow"), follow_redirects=True) assert b'1 watches queued for rechecking.' in res.data - time.sleep(2) + wait_for_all_checks(client) # Enable password check and diff page access bypass res = c.post( diff --git a/changedetectionio/tests/test_add_replace_remove_filter.py b/changedetectionio/tests/test_add_replace_remove_filter.py index 4ad9ecf86..5562a23bd 100644 --- a/changedetectionio/tests/test_add_replace_remove_filter.py +++ b/changedetectionio/tests/test_add_replace_remove_filter.py @@ -41,7 +41,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_api.py b/changedetectionio/tests/test_api.py index c19812abc..3f2f53402 100644 --- a/changedetectionio/tests/test_api.py +++ b/changedetectionio/tests/test_api.py @@ -267,7 +267,7 @@ def test_api_watch_PUT_update(client, live_server): #live_server_setup(live_server) api_key = extract_api_key_from_UI(client) - time.sleep(1) + wait_for_all_checks(client) # Create a watch set_original_response() test_url = url_for('test_endpoint', _external=True, @@ -283,7 +283,7 @@ def test_api_watch_PUT_update(client, live_server): assert res.status_code == 201 - time.sleep(1) + wait_for_all_checks(client) # Get a listing, it will be the first one res = client.get( diff --git a/changedetectionio/tests/test_auth.py b/changedetectionio/tests/test_auth.py index b84f8cf71..40e208f07 100644 --- a/changedetectionio/tests/test_auth.py +++ b/changedetectionio/tests/test_auth.py @@ -19,7 +19,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 +29,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 c95e8fcf0..026a791ea 100644 --- a/changedetectionio/tests/test_automatic_follow_ldjson_price.py +++ b/changedetectionio/tests/test_automatic_follow_ldjson_price.py @@ -2,7 +2,8 @@ import time from flask import url_for -from .util import live_server_setup, extract_UUID_from_client, extract_api_key_from_UI +from .util import live_server_setup, extract_UUID_from_client, extract_api_key_from_UI, wait_for_all_checks + def set_response_with_ldjson(): test_return_data = """ @@ -92,7 +93,7 @@ def test_check_ldjson_price_autodetect(client, live_server): follow_redirects=True ) assert b"1 Imported" in res.data - time.sleep(3) + wait_for_all_checks(client) # Should get a notice that it's available res = client.get(url_for("index")) @@ -102,11 +103,11 @@ def test_check_ldjson_price_autodetect(client, live_server): uuid = extract_UUID_from_client(client) client.get(url_for('price_data_follower.accept', uuid=uuid, follow_redirects=True)) - time.sleep(2) + wait_for_all_checks(client) # Trigger a check client.get(url_for("form_watch_checknow"), follow_redirects=True) - time.sleep(2) + wait_for_all_checks(client) # Offer should be gone res = client.get(url_for("index")) assert b'Embedded price data' not in res.data @@ -138,7 +139,7 @@ def test_check_ldjson_price_autodetect(client, live_server): follow_redirects=True ) assert b"1 Imported" in res.data - time.sleep(3) + wait_for_all_checks(client) res = client.get(url_for("index")) assert b'ldjson-price-track-offer' not in res.data diff --git a/changedetectionio/tests/test_backend.py b/changedetectionio/tests/test_backend.py index 03c135fcf..ea7212201 100644 --- a/changedetectionio/tests/test_backend.py +++ b/changedetectionio/tests/test_backend.py @@ -28,8 +28,7 @@ def test_check_basic_change_detection_functionality(client, live_server): ) assert b"1 Imported" in res.data - - time.sleep(sleep_time_for_fetch_thread) + wait_for_all_checks(client) # Do this a few times.. ensures we dont accidently set the status for n in range(3): diff --git a/changedetectionio/tests/test_backup.py b/changedetectionio/tests/test_backup.py index 89fd66a5d..777fbfc52 100644 --- a/changedetectionio/tests/test_backup.py +++ b/changedetectionio/tests/test_backup.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -from .util import set_original_response, set_modified_response, live_server_setup +from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks from flask import url_for from urllib.request import urlopen from zipfile import ZipFile @@ -24,7 +24,7 @@ def test_backup(client, live_server): ) assert b"1 Imported" in res.data - time.sleep(3) + wait_for_all_checks(client) res = client.get( url_for("get_backup"), diff --git a/changedetectionio/tests/test_css_selector.py b/changedetectionio/tests/test_css_selector.py index 0dfe2af78..fd40299d3 100644 --- a/changedetectionio/tests/test_css_selector.py +++ b/changedetectionio/tests/test_css_selector.py @@ -2,7 +2,7 @@ import time from flask import url_for -from . util import live_server_setup +from .util import live_server_setup, wait_for_all_checks from ..html_tools import * @@ -90,7 +90,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,7 +100,7 @@ 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"), @@ -108,14 +108,14 @@ def test_check_markup_include_filters_restriction(client, live_server): 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 @@ -139,7 +139,7 @@ def test_check_multiple_filters(client, live_server): """) # Give the endpoint time to spin up - time.sleep(1) + wait_for_all_checks(client) # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) @@ -149,7 +149,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 @@ -165,7 +165,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"), diff --git a/changedetectionio/tests/test_element_removal.py b/changedetectionio/tests/test_element_removal.py index 3c280d221..a084b6f2d 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): @@ -120,7 +120,7 @@ def test_element_removal_full(client, live_server): 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" @@ -147,7 +147,7 @@ def test_element_removal_full(client, live_server): 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) # so that we set the state to 'unviewed' after all the edits client.get(url_for("diff_history_page", uuid="first")) diff --git a/changedetectionio/tests/test_errorhandling.py b/changedetectionio/tests/test_errorhandling.py index bd3d9d6f7..5054c69a4 100644 --- a/changedetectionio/tests/test_errorhandling.py +++ b/changedetectionio/tests/test_errorhandling.py @@ -3,7 +3,7 @@ import time from flask import url_for -from . util import live_server_setup +from .util import live_server_setup, wait_for_all_checks from ..html_tools import * @@ -30,7 +30,7 @@ def _runner_test_http_errors(client, live_server, http_code, expected_text): assert b"1 Imported" in res.data # Give the thread time to pick it up - time.sleep(2) + wait_for_all_checks(client) res = client.get(url_for("index")) # no change @@ -76,7 +76,7 @@ def test_DNS_errors(client, live_server): assert b"1 Imported" in res.data # Give the thread time to pick it up - time.sleep(3) + wait_for_all_checks(client) res = client.get(url_for("index")) found_name_resolution_error = b"Temporary failure in name resolution" in res.data or b"Name or service not known" in res.data @@ -90,7 +90,7 @@ def test_DNS_errors(client, live_server): 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) + #time.sleep(1) with open("test-datastore/endpoint-content.txt", "w") as f: f.write("