From 43ddfa5005b93d80a1ab4d0b72108e3dad711be2 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 17 Jun 2024 18:42:06 +0200 Subject: [PATCH] Add delay --- changedetectionio/tests/test_request.py | 11 ++++++++--- changedetectionio/tests/util.py | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/changedetectionio/tests/test_request.py b/changedetectionio/tests/test_request.py index c9159195..896b2c80 100644 --- a/changedetectionio/tests/test_request.py +++ b/changedetectionio/tests/test_request.py @@ -10,6 +10,7 @@ def test_setup(live_server): # Hard to just add more live server URLs when one test is already running (I think) # So we add our test here (was in a different file) def test_headers_in_request(client, live_server): + #ve_server_setup(live_server) # Add our URL to the import page test_url = url_for('test_headers', _external=True) @@ -378,13 +379,17 @@ def test_headers_textfile_in_request(client, live_server): with open('test-datastore/' + extract_UUID_from_client(client) + '/headers.txt', 'w') as f: f.write("watch-header: nice") - # seems to weird when run on github - time.sleep(2) + wait_for_all_checks(client) client.get(url_for("form_watch_checknow"), follow_redirects=True) - # Give the thread time to pick it up + # Give the thread time to pick it up, this actually is not super reliable and pytest can terminate before the check is ran wait_for_all_checks(client) + # WARNING - pytest and 'wait_for_all_checks' shuts down before it has actually stopped processing when using pyppeteer fetcher + # so adding more time here + if os.getenv('FAST_PUPPETEER_CHROME_FETCHER'): + time.sleep(6) + res = client.get(url_for("edit_page", uuid="first")) assert b"Extra headers file found and will be added to this watch" in res.data diff --git a/changedetectionio/tests/util.py b/changedetectionio/tests/util.py index 51ad2497..f97a0351 100644 --- a/changedetectionio/tests/util.py +++ b/changedetectionio/tests/util.py @@ -121,6 +121,7 @@ def extract_UUID_from_client(client): return uuid.strip() def wait_for_all_checks(client): + # actually this is not entirely true, it can still be 'processing' but not in the queue # Loop waiting until done.. attempt=0 # because sub-second rechecks are problematic in testing, use lots of delays