diff --git a/changedetectionio/tests/conftest.py b/changedetectionio/tests/conftest.py index be32f6ee1..3e7069caa 100644 --- a/changedetectionio/tests/conftest.py +++ b/changedetectionio/tests/conftest.py @@ -10,6 +10,8 @@ import os import sys from loguru import logger +from changedetectionio.tests.util import live_server_setup, new_live_server_setup + # https://github.com/pallets/flask/blob/1.1.2/examples/tutorial/tests/test_auth.py # Much better boilerplate than the docs # https://www.python-boilerplate.com/py3+flask+pytest/ @@ -70,6 +72,22 @@ def cleanup(datastore_path): if os.path.isfile(f): os.unlink(f) +@pytest.fixture(scope='function', autouse=True) +def prepare_test_function(live_server): + + routes = [rule.rule for rule in live_server.app.url_map.iter_rules()] + if '/test-random-content-endpoint' not in routes: + logger.debug("Setting up test URL routes") + new_live_server_setup(live_server) + + + yield + # Then cleanup/shutdown + live_server.app.config['DATASTORE'].data['watching']={} + time.sleep(0.3) + live_server.app.config['DATASTORE'].data['watching']={} + + @pytest.fixture(scope='session') def app(request): """Create application for the tests.""" diff --git a/changedetectionio/tests/custom_browser_url/test_custom_browser_url.py b/changedetectionio/tests/custom_browser_url/test_custom_browser_url.py index efc6e127d..6ec4205ee 100644 --- a/changedetectionio/tests/custom_browser_url/test_custom_browser_url.py +++ b/changedetectionio/tests/custom_browser_url/test_custom_browser_url.py @@ -78,12 +78,12 @@ def do_test(client, live_server, make_test_use_extra_browser=False): # Requires playwright to be installed def test_request_via_custom_browser_url(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # We do this so we can grep the logs of the custom container and see if the request actually went through that container do_test(client, live_server, make_test_use_extra_browser=True) def test_request_not_via_custom_browser_url(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # We do this so we can grep the logs of the custom container and see if the request actually went through that container do_test(client, live_server, make_test_use_extra_browser=False) diff --git a/changedetectionio/tests/fetchers/test_content.py b/changedetectionio/tests/fetchers/test_content.py index dc02f50c7..e09781c55 100644 --- a/changedetectionio/tests/fetchers/test_content.py +++ b/changedetectionio/tests/fetchers/test_content.py @@ -7,7 +7,7 @@ import logging # Requires playwright to be installed def test_fetch_webdriver_content(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function ##################### res = client.post( diff --git a/changedetectionio/tests/fetchers/test_custom_js_before_content.py b/changedetectionio/tests/fetchers/test_custom_js_before_content.py index e145a79ea..cb4d6286c 100644 --- a/changedetectionio/tests/fetchers/test_custom_js_before_content.py +++ b/changedetectionio/tests/fetchers/test_custom_js_before_content.py @@ -5,7 +5,7 @@ from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_cli def test_execute_custom_js(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function assert os.getenv('PLAYWRIGHT_DRIVER_URL'), "Needs PLAYWRIGHT_DRIVER_URL set for this test" test_url = url_for('test_interactive_html_endpoint', _external=True) diff --git a/changedetectionio/tests/proxy_list/test_multiple_proxy.py b/changedetectionio/tests/proxy_list/test_multiple_proxy.py index f1818e3a3..cc0da45f4 100644 --- a/changedetectionio/tests/proxy_list/test_multiple_proxy.py +++ b/changedetectionio/tests/proxy_list/test_multiple_proxy.py @@ -6,7 +6,7 @@ from ..util import live_server_setup, wait_for_all_checks def test_preferred_proxy(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function url = "http://chosen.changedetection.io" diff --git a/changedetectionio/tests/proxy_list/test_noproxy.py b/changedetectionio/tests/proxy_list/test_noproxy.py index ffae929b6..fdd9aa354 100644 --- a/changedetectionio/tests/proxy_list/test_noproxy.py +++ b/changedetectionio/tests/proxy_list/test_noproxy.py @@ -6,7 +6,7 @@ from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_cli def test_noproxy_option(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # Run by run_proxy_tests.sh # Call this URL then scan the containers that it never went through them url = "http://noproxy.changedetection.io" diff --git a/changedetectionio/tests/proxy_list/test_proxy.py b/changedetectionio/tests/proxy_list/test_proxy.py index 726d0c82b..bda17d1b6 100644 --- a/changedetectionio/tests/proxy_list/test_proxy.py +++ b/changedetectionio/tests/proxy_list/test_proxy.py @@ -6,7 +6,7 @@ from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_cli # just make a request, we will grep in the docker logs to see it actually got called def test_check_basic_change_detection_functionality(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function res = client.post( url_for("imports.import_page"), # Because a URL wont show in squid/proxy logs due it being SSLed diff --git a/changedetectionio/tests/proxy_list/test_proxy_noconnect.py b/changedetectionio/tests/proxy_list/test_proxy_noconnect.py index 72f3e512c..31edaadb2 100644 --- a/changedetectionio/tests/proxy_list/test_proxy_noconnect.py +++ b/changedetectionio/tests/proxy_list/test_proxy_noconnect.py @@ -13,7 +13,7 @@ from ... import strtobool # WEBDRIVER_URL=http://127.0.0.1:4444/wd/hub pytest tests/proxy_list/test_proxy_noconnect.py def test_proxy_noconnect_custom(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # Goto settings, add our custom one res = client.post( diff --git a/changedetectionio/tests/proxy_list/test_select_custom_proxy.py b/changedetectionio/tests/proxy_list/test_select_custom_proxy.py index e35c37181..ab8313587 100644 --- a/changedetectionio/tests/proxy_list/test_select_custom_proxy.py +++ b/changedetectionio/tests/proxy_list/test_select_custom_proxy.py @@ -7,7 +7,7 @@ import os # just make a request, we will grep in the docker logs to see it actually got called def test_select_custom(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # Goto settings, add our custom one res = client.post( diff --git a/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py b/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py index 3d0271a84..f2595bd01 100644 --- a/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py +++ b/changedetectionio/tests/proxy_socks5/test_socks5_proxy.py @@ -20,7 +20,7 @@ def set_response(): time.sleep(1) def test_socks5(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function set_response() # Setup a proxy diff --git a/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py b/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py index 040248431..3805c88d1 100644 --- a/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py +++ b/changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py @@ -21,7 +21,7 @@ def set_response(): # should be proxies.json mounted from run_proxy_tests.sh already # -v `pwd`/tests/proxy_socks5/proxies.json-example:/app/changedetectionio/test-datastore/proxies.json def test_socks5_from_proxiesjson_file(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function set_response() # Because the socks server should connect back to us test_url = url_for('test_endpoint', _external=True) + f"?socks-test-tag={os.getenv('SOCKSTEST', '')}" diff --git a/changedetectionio/tests/restock/test_restock.py b/changedetectionio/tests/restock/test_restock.py index 1d1accec7..ecee00fab 100644 --- a/changedetectionio/tests/restock/test_restock.py +++ b/changedetectionio/tests/restock/test_restock.py @@ -54,7 +54,7 @@ def test_restock_detection(client, live_server, measure_memory_usage): set_original_response() #assert os.getenv('PLAYWRIGHT_DRIVER_URL'), "Needs PLAYWRIGHT_DRIVER_URL set for this test" - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function ##################### notification_url = url_for('test_notification_endpoint', _external=True).replace('http://localhost', 'http://changedet').replace('http', 'json') diff --git a/changedetectionio/tests/smtp/test_notification_smtp.py b/changedetectionio/tests/smtp/test_notification_smtp.py index ea17a2b57..a400901c4 100644 --- a/changedetectionio/tests/smtp/test_notification_smtp.py +++ b/changedetectionio/tests/smtp/test_notification_smtp.py @@ -20,8 +20,7 @@ from changedetectionio.notification import ( valid_notification_formats, ) -def test_setup(live_server): - live_server_setup(live_server) + def get_last_message_from_smtp_server(): import socket @@ -40,7 +39,7 @@ def get_last_message_from_smtp_server(): # Requires running the test SMTP server def test_check_notification_email_formats_default_HTML(client, live_server, measure_memory_usage): - # live_server_setup(live_server) + ## live_server_setup(live_server) # Setup on conftest per function set_original_response() notification_url = f'mailto://changedetection@{smtp_test_server}:11025/?to=fff@home.com' @@ -91,7 +90,7 @@ def test_check_notification_email_formats_default_HTML(client, live_server, meas def test_check_notification_email_formats_default_Text_override_HTML(client, live_server, measure_memory_usage): - # live_server_setup(live_server) + ## live_server_setup(live_server) # Setup on conftest per function # HTML problems? see this # https://github.com/caronc/apprise/issues/633 diff --git a/changedetectionio/tests/test_access_control.py b/changedetectionio/tests/test_access_control.py index b35de2684..a72e64a9a 100644 --- a/changedetectionio/tests/test_access_control.py +++ b/changedetectionio/tests/test_access_control.py @@ -4,7 +4,7 @@ import time def test_check_access_control(app, client, live_server): # Still doesnt work, but this is closer. - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function with app.test_client(use_cookies=True) as c: # Check we don't have any password protection enabled yet. diff --git a/changedetectionio/tests/test_add_replace_remove_filter.py b/changedetectionio/tests/test_add_replace_remove_filter.py index 4d0329ebe..e119be49f 100644 --- a/changedetectionio/tests/test_add_replace_remove_filter.py +++ b/changedetectionio/tests/test_add_replace_remove_filter.py @@ -35,15 +35,11 @@ def set_original(excluding=None, add_line=None): with open("test-datastore/endpoint-content.txt", "w") as f: f.write(test_return_data) -def test_setup(client, live_server, measure_memory_usage): - live_server_setup(live_server) +# def test_setup(client, live_server, measure_memory_usage): + # live_server_setup(live_server) # Setup on conftest per function def test_check_removed_line_contains_trigger(client, live_server, measure_memory_usage): - res = client.get(url_for("ui.form_delete", uuid="all"), follow_redirects=True) - assert b'Deleted' in res.data - time.sleep(1) - #live_server_setup(live_server) # Give the endpoint time to spin up set_original() # Add our URL to the import page @@ -76,6 +72,7 @@ def test_check_removed_line_contains_trigger(client, live_server, measure_memory res = client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) assert b'Queued 1 watch for rechecking.' in res.data wait_for_all_checks(client) + time.sleep(0.5) res = client.get(url_for("watchlist.index")) assert b'unviewed' not in res.data @@ -88,12 +85,15 @@ def test_check_removed_line_contains_trigger(client, live_server, measure_memory res = client.get(url_for("watchlist.index")) assert b'unviewed' in res.data + time.sleep(1) # Now add it back, and we should not get a trigger client.get(url_for("ui.mark_all_viewed"), follow_redirects=True) + time.sleep(1) set_original(excluding=None) client.get(url_for("ui.form_watch_checknow"), follow_redirects=True) wait_for_all_checks(client) + time.sleep(1) res = client.get(url_for("watchlist.index")) assert b'unviewed' not in res.data @@ -109,7 +109,7 @@ def test_check_removed_line_contains_trigger(client, live_server, measure_memory def test_check_add_line_contains_trigger(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + res = client.get(url_for("ui.form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data time.sleep(1) diff --git a/changedetectionio/tests/test_api.py b/changedetectionio/tests/test_api.py index 4aa7fec7e..2cd87e5bc 100644 --- a/changedetectionio/tests/test_api.py +++ b/changedetectionio/tests/test_api.py @@ -52,12 +52,12 @@ def is_valid_uuid(val): return False -def test_setup(client, live_server, measure_memory_usage): - live_server_setup(live_server) +# def test_setup(client, live_server, measure_memory_usage): + # live_server_setup(live_server) # Setup on conftest per function def test_api_simple(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + api_key = live_server.app.config['DATASTORE'].data['settings']['application'].get('api_access_token') @@ -292,7 +292,7 @@ def test_access_denied(client, live_server, measure_memory_usage): def test_api_watch_PUT_update(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + api_key = live_server.app.config['DATASTORE'].data['settings']['application'].get('api_access_token') # Create a watch @@ -372,7 +372,7 @@ def test_api_watch_PUT_update(client, live_server, measure_memory_usage): def test_api_import(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + api_key = live_server.app.config['DATASTORE'].data['settings']['application'].get('api_access_token') res = client.post( @@ -394,7 +394,7 @@ def test_api_import(client, live_server, measure_memory_usage): def test_api_conflict_UI_password(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + api_key = live_server.app.config['DATASTORE'].data['settings']['application'].get('api_access_token') # Enable password check and diff page access bypass diff --git a/changedetectionio/tests/test_api_notifications.py b/changedetectionio/tests/test_api_notifications.py index 9a030e66b..d8bad0aa9 100644 --- a/changedetectionio/tests/test_api_notifications.py +++ b/changedetectionio/tests/test_api_notifications.py @@ -5,7 +5,7 @@ from .util import live_server_setup import json def test_api_notifications_crud(client, live_server): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function api_key = live_server.app.config['DATASTORE'].data['settings']['application'].get('api_access_token') # Confirm notifications are initially empty diff --git a/changedetectionio/tests/test_api_search.py b/changedetectionio/tests/test_api_search.py index 3369905ef..7f7dd6a38 100644 --- a/changedetectionio/tests/test_api_search.py +++ b/changedetectionio/tests/test_api_search.py @@ -7,7 +7,7 @@ from .util import live_server_setup, wait_for_all_checks def test_api_search(client, live_server): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function api_key = live_server.app.config['DATASTORE'].data['settings']['application'].get('api_access_token') watch_data = {} diff --git a/changedetectionio/tests/test_api_tags.py b/changedetectionio/tests/test_api_tags.py index 55131d6db..831d052e8 100644 --- a/changedetectionio/tests/test_api_tags.py +++ b/changedetectionio/tests/test_api_tags.py @@ -5,7 +5,7 @@ from .util import live_server_setup, wait_for_all_checks import json def test_api_tags_listing(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function api_key = live_server.app.config['DATASTORE'].data['settings']['application'].get('api_access_token') tag_title = 'Test Tag' diff --git a/changedetectionio/tests/test_auth.py b/changedetectionio/tests/test_auth.py index b3065fc0e..a98599619 100644 --- a/changedetectionio/tests/test_auth.py +++ b/changedetectionio/tests/test_auth.py @@ -6,7 +6,7 @@ from .util import live_server_setup, wait_for_all_checks # test pages with http://username@password:foobar.com/ work def test_basic_auth(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # This page will echo back any auth info diff --git a/changedetectionio/tests/test_automatic_follow_ldjson_price.py b/changedetectionio/tests/test_automatic_follow_ldjson_price.py index f1908053a..c730286c9 100644 --- a/changedetectionio/tests/test_automatic_follow_ldjson_price.py +++ b/changedetectionio/tests/test_automatic_follow_ldjson_price.py @@ -76,12 +76,12 @@ def set_response_without_ldjson(): f.write(test_return_data) return None -def test_setup(client, live_server, measure_memory_usage): - live_server_setup(live_server) +# def test_setup(client, live_server, measure_memory_usage): + # live_server_setup(live_server) # Setup on conftest per function # actually only really used by the distll.io importer, but could be handy too def test_check_ldjson_price_autodetect(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + set_response_with_ldjson() # Add our URL to the import page @@ -164,7 +164,7 @@ def _test_runner_check_bad_format_ignored(live_server, client, has_ldjson_price_ def test_bad_ldjson_is_correctly_ignored(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + test_return_data = """ diff --git a/changedetectionio/tests/test_backend.py b/changedetectionio/tests/test_backend.py index de0c169e4..f85fcaf2e 100644 --- a/changedetectionio/tests/test_backend.py +++ b/changedetectionio/tests/test_backend.py @@ -18,7 +18,7 @@ def test_inscriptus(): def test_check_basic_change_detection_functionality(client, live_server, measure_memory_usage): set_original_response() - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # Add our URL to the import page res = client.post( diff --git a/changedetectionio/tests/test_backup.py b/changedetectionio/tests/test_backup.py index 16366e911..ca1a0c6f6 100644 --- a/changedetectionio/tests/test_backup.py +++ b/changedetectionio/tests/test_backup.py @@ -9,7 +9,7 @@ import time def test_backup(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function set_original_response() diff --git a/changedetectionio/tests/test_basic_socketio.py b/changedetectionio/tests/test_basic_socketio.py index 82a31e222..1c48e758b 100644 --- a/changedetectionio/tests/test_basic_socketio.py +++ b/changedetectionio/tests/test_basic_socketio.py @@ -110,7 +110,7 @@ def run_socketio_watch_update_test(client, live_server, password_mode=""): def test_everything(live_server, client): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function run_socketio_watch_update_test(password_mode="", live_server=live_server, client=client) diff --git a/changedetectionio/tests/test_block_while_text_present.py b/changedetectionio/tests/test_block_while_text_present.py index 473f5645f..6ab36855f 100644 --- a/changedetectionio/tests/test_block_while_text_present.py +++ b/changedetectionio/tests/test_block_while_text_present.py @@ -62,7 +62,7 @@ def set_modified_response_minus_block_text(): def test_check_block_changedetection_text_NOT_present(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # Use a mix of case in ZzZ to prove it works case-insensitive. ignore_text = "out of stoCk\r\nfoobar" set_original_ignore_response() diff --git a/changedetectionio/tests/test_clone.py b/changedetectionio/tests/test_clone.py index fd43384ae..aeb3b4f2a 100644 --- a/changedetectionio/tests/test_clone.py +++ b/changedetectionio/tests/test_clone.py @@ -7,7 +7,7 @@ from .util import live_server_setup, wait_for_all_checks def test_clone_functionality(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function with open("test-datastore/endpoint-content.txt", "w") as f: f.write("Some content") diff --git a/changedetectionio/tests/test_conditions.py b/changedetectionio/tests/test_conditions.py index 14dde0245..e6c453d35 100644 --- a/changedetectionio/tests/test_conditions.py +++ b/changedetectionio/tests/test_conditions.py @@ -45,15 +45,15 @@ def set_number_out_of_range_response(number="150"): f.write(test_return_data) -def test_setup(client, live_server): +# def test_setup(client, live_server): """Test that both text and number conditions work together with AND logic.""" - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function def test_conditions_with_text_and_number(client, live_server): """Test that both text and number conditions work together with AND logic.""" set_original_response("50") - #live_server_setup(live_server) + test_url = url_for('test_endpoint', _external=True) @@ -206,7 +206,7 @@ def test_condition_validate_rule_row(client, live_server): # If there was only a change in the whitespacing, then we shouldnt have a change detected def test_wordcount_conditions_plugin(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + test_return_data = """ @@ -249,7 +249,7 @@ def test_wordcount_conditions_plugin(client, live_server, measure_memory_usage): # If there was only a change in the whitespacing, then we shouldnt have a change detected def test_lev_conditions_plugin(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + with open("test-datastore/endpoint-content.txt", "w") as f: f.write(""" diff --git a/changedetectionio/tests/test_css_selector.py b/changedetectionio/tests/test_css_selector.py index 545d97f09..bad181c25 100644 --- a/changedetectionio/tests/test_css_selector.py +++ b/changedetectionio/tests/test_css_selector.py @@ -6,8 +6,7 @@ from .util import live_server_setup, wait_for_all_checks from ..html_tools import * -def test_setup(live_server): - live_server_setup(live_server) + def set_original_response(): test_return_data = """ @@ -125,7 +124,7 @@ def test_check_markup_include_filters_restriction(client, live_server, measure_m # Tests the whole stack works with the CSS Filter def test_check_multiple_filters(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + include_filters = "#blob-a\r\nxpath://*[contains(@id,'blob-b')]" with open("test-datastore/endpoint-content.txt", "w") as f: @@ -177,7 +176,7 @@ def test_check_multiple_filters(client, live_server, measure_memory_usage): # Mainly used when the filter contains just an IMG, this can happen when someone selects an image in the visual-selector # Tests fetcher can throw a "ReplyWithContentButNoText" exception after applying filter and extracting text def test_filter_is_empty_help_suggestion(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + include_filters = "#blob-a" diff --git a/changedetectionio/tests/test_element_removal.py b/changedetectionio/tests/test_element_removal.py index b4a310792..36643b713 100644 --- a/changedetectionio/tests/test_element_removal.py +++ b/changedetectionio/tests/test_element_removal.py @@ -8,8 +8,7 @@ from ..html_tools import * from .util import live_server_setup, wait_for_all_checks -def test_setup(live_server): - live_server_setup(live_server) + def set_response_with_multiple_index(): data= """ @@ -148,7 +147,7 @@ across multiple lines def test_element_removal_full(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + set_original_response() @@ -209,7 +208,7 @@ def test_element_removal_full(client, live_server, measure_memory_usage): # Re #2752 def test_element_removal_nth_offset_no_shift(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + set_response_with_multiple_index() subtractive_selectors_data = [""" diff --git a/changedetectionio/tests/test_encoding.py b/changedetectionio/tests/test_encoding.py index d70dc56a5..722d1e6b8 100644 --- a/changedetectionio/tests/test_encoding.py +++ b/changedetectionio/tests/test_encoding.py @@ -7,8 +7,7 @@ from .util import live_server_setup, wait_for_all_checks, extract_UUID_from_clie import pytest -def test_setup(live_server): - live_server_setup(live_server) + def set_html_response(): diff --git a/changedetectionio/tests/test_errorhandling.py b/changedetectionio/tests/test_errorhandling.py index 40c89242c..27b9a3188 100644 --- a/changedetectionio/tests/test_errorhandling.py +++ b/changedetectionio/tests/test_errorhandling.py @@ -5,8 +5,7 @@ import time from flask import url_for from .util import live_server_setup, wait_for_all_checks -def test_setup(live_server): - live_server_setup(live_server) + def _runner_test_http_errors(client, live_server, http_code, expected_text): @@ -93,7 +92,7 @@ def test_DNS_errors(client, live_server, measure_memory_usage): # Re 1513 def test_low_level_errors_clear_correctly(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + # Give the endpoint time to spin up time.sleep(1) diff --git a/changedetectionio/tests/test_extract_csv.py b/changedetectionio/tests/test_extract_csv.py index e7073638f..e70c41b26 100644 --- a/changedetectionio/tests/test_extract_csv.py +++ b/changedetectionio/tests/test_extract_csv.py @@ -14,7 +14,7 @@ def test_check_extract_text_from_diff(client, live_server, measure_memory_usage) with open("test-datastore/endpoint-content.txt", "w") as f: f.write("Now it's {} seconds since epoch, time flies!".format(str(time.time()))) - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # Add our URL to the import page res = client.post( diff --git a/changedetectionio/tests/test_extract_regex.py b/changedetectionio/tests/test_extract_regex.py index 68155ff16..3b270d3fa 100644 --- a/changedetectionio/tests/test_extract_regex.py +++ b/changedetectionio/tests/test_extract_regex.py @@ -67,11 +67,11 @@ def set_multiline_response(): return None -def test_setup(client, live_server, measure_memory_usage): - live_server_setup(live_server) +# def test_setup(client, live_server, measure_memory_usage): + # live_server_setup(live_server) # Setup on conftest per function def test_check_filter_multiline(client, live_server, measure_memory_usage): - # live_server_setup(live_server) + ## live_server_setup(live_server) # Setup on conftest per function set_multiline_response() # Add our URL to the import page @@ -206,7 +206,7 @@ def test_check_filter_and_regex_extract(client, live_server, measure_memory_usag def test_regex_error_handling(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) diff --git a/changedetectionio/tests/test_filter_exist_changes.py b/changedetectionio/tests/test_filter_exist_changes.py index 9b2f93507..c7841bad7 100644 --- a/changedetectionio/tests/test_filter_exist_changes.py +++ b/changedetectionio/tests/test_filter_exist_changes.py @@ -46,7 +46,7 @@ def test_filter_doesnt_exist_then_exists_should_get_notification(client, live_se # And the page has that filter available # Then I should get a notification - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # Give the endpoint time to spin up time.sleep(1) diff --git a/changedetectionio/tests/test_filter_failure_notification.py b/changedetectionio/tests/test_filter_failure_notification.py index fcb13d88a..7023fb55a 100644 --- a/changedetectionio/tests/test_filter_failure_notification.py +++ b/changedetectionio/tests/test_filter_failure_notification.py @@ -163,15 +163,14 @@ def run_filter_test(client, live_server, content_filter): os.unlink("test-datastore/notification.txt") -def test_setup(live_server): - live_server_setup(live_server) + def test_check_include_filters_failure_notification(client, live_server, measure_memory_usage): -# live_server_setup(live_server) +# # live_server_setup(live_server) # Setup on conftest per function run_filter_test(client, live_server,'#nope-doesnt-exist') def test_check_xpath_filter_failure_notification(client, live_server, measure_memory_usage): -# live_server_setup(live_server) +# # live_server_setup(live_server) # Setup on conftest per function run_filter_test(client, live_server, '//*[@id="nope-doesnt-exist"]') # Test that notification is never sent diff --git a/changedetectionio/tests/test_group.py b/changedetectionio/tests/test_group.py index ae294d407..400b60cd3 100644 --- a/changedetectionio/tests/test_group.py +++ b/changedetectionio/tests/test_group.py @@ -6,8 +6,8 @@ from .util import live_server_setup, wait_for_all_checks, extract_rss_token_from import os -def test_setup(client, live_server, measure_memory_usage): - live_server_setup(live_server) +# def test_setup(client, live_server, measure_memory_usage): + # live_server_setup(live_server) # Setup on conftest per function def set_original_response(): test_return_data = """ @@ -39,8 +39,8 @@ def set_modified_response(): f.write(test_return_data) return None -def test_setup_group_tag(client, live_server, measure_memory_usage): - #live_server_setup(live_server) +# def test_setup_group_tag(client, live_server, measure_memory_usage): + set_original_response() # Add a tag with some config, import a tag and it should roughly work @@ -131,7 +131,7 @@ def test_setup_group_tag(client, live_server, measure_memory_usage): assert b'Deleted' in res.data def test_tag_import_singular(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + test_url = url_for('test_endpoint', _external=True) res = client.post( @@ -151,7 +151,7 @@ def test_tag_import_singular(client, live_server, measure_memory_usage): assert b'Deleted' in res.data def test_tag_add_in_ui(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + # res = client.post( url_for("tags.form_tag_add"), @@ -168,7 +168,7 @@ def test_tag_add_in_ui(client, live_server, measure_memory_usage): assert b'Deleted' in res.data def test_group_tag_notification(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + set_original_response() test_url = url_for('test_endpoint', _external=True) @@ -236,7 +236,7 @@ def test_group_tag_notification(client, live_server, measure_memory_usage): assert b'Deleted' in res.data def test_limit_tag_ui(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + test_url = url_for('test_endpoint', _external=True) urls=[] @@ -275,7 +275,7 @@ def test_limit_tag_ui(client, live_server, measure_memory_usage): assert b'All tags deleted' in res.data def test_clone_tag_on_import(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + test_url = url_for('test_endpoint', _external=True) res = client.post( url_for("imports.import_page"), @@ -301,7 +301,7 @@ def test_clone_tag_on_import(client, live_server, measure_memory_usage): assert b'Deleted' in res.data def test_clone_tag_on_quickwatchform_add(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + test_url = url_for('test_endpoint', _external=True) diff --git a/changedetectionio/tests/test_history_consistency.py b/changedetectionio/tests/test_history_consistency.py index 1558c275d..fbcfba4d1 100644 --- a/changedetectionio/tests/test_history_consistency.py +++ b/changedetectionio/tests/test_history_consistency.py @@ -9,7 +9,7 @@ from .util import live_server_setup, wait_for_all_checks from urllib.parse import urlparse, parse_qs def test_consistent_history(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function workers = int(os.getenv("FETCH_WORKERS", 10)) r = range(1, 10+workers) diff --git a/changedetectionio/tests/test_ignore.py b/changedetectionio/tests/test_ignore.py index 1a88c0b73..985e58b8b 100644 --- a/changedetectionio/tests/test_ignore.py +++ b/changedetectionio/tests/test_ignore.py @@ -24,7 +24,7 @@ def set_original_ignore_response(): def test_ignore(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function set_original_ignore_response() test_url = url_for('test_endpoint', _external=True) res = client.post( diff --git a/changedetectionio/tests/test_ignore_regex_text.py b/changedetectionio/tests/test_ignore_regex_text.py index dca89817f..847a3e745 100644 --- a/changedetectionio/tests/test_ignore_regex_text.py +++ b/changedetectionio/tests/test_ignore_regex_text.py @@ -3,8 +3,7 @@ from . util import live_server_setup from changedetectionio import html_tools -def test_setup(live_server): - live_server_setup(live_server) + # Unit test of the stripper # Always we are dealing in utf-8 diff --git a/changedetectionio/tests/test_ignore_text.py b/changedetectionio/tests/test_ignore_text.py index 7864e08e4..19fe23030 100644 --- a/changedetectionio/tests/test_ignore_text.py +++ b/changedetectionio/tests/test_ignore_text.py @@ -5,8 +5,7 @@ from flask import url_for from .util import live_server_setup, wait_for_all_checks from changedetectionio import html_tools -def test_setup(live_server): - live_server_setup(live_server) + # Unit test of the stripper # Always we are dealing in utf-8 @@ -256,9 +255,9 @@ def _run_test_global_ignore(client, as_source=False, extra_ignore=""): assert b'Deleted' in res.data def test_check_global_ignore_text_functionality(client, live_server): - #live_server_setup(live_server) + _run_test_global_ignore(client, as_source=False) def test_check_global_ignore_text_functionality_as_source(client, live_server): - #live_server_setup(live_server) + _run_test_global_ignore(client, as_source=True, extra_ignore='/\?v=\d/') diff --git a/changedetectionio/tests/test_ignorehyperlinks.py b/changedetectionio/tests/test_ignorehyperlinks.py index 34b43a1f4..5df8f9ae4 100644 --- a/changedetectionio/tests/test_ignorehyperlinks.py +++ b/changedetectionio/tests/test_ignorehyperlinks.py @@ -6,8 +6,7 @@ from flask import url_for from .util import live_server_setup, wait_for_all_checks -def test_setup(live_server): - live_server_setup(live_server) + def set_original_ignore_response(): test_return_data = """ diff --git a/changedetectionio/tests/test_ignorestatuscode.py b/changedetectionio/tests/test_ignorestatuscode.py index cac971bec..a28e8996a 100644 --- a/changedetectionio/tests/test_ignorestatuscode.py +++ b/changedetectionio/tests/test_ignorestatuscode.py @@ -5,8 +5,7 @@ from flask import url_for from .util import live_server_setup, wait_for_all_checks -def test_setup(live_server): - live_server_setup(live_server) + def set_original_response(): diff --git a/changedetectionio/tests/test_ignorewhitespace.py b/changedetectionio/tests/test_ignorewhitespace.py index fe97d6cad..93fa94b2e 100644 --- a/changedetectionio/tests/test_ignorewhitespace.py +++ b/changedetectionio/tests/test_ignorewhitespace.py @@ -4,8 +4,7 @@ import time from flask import url_for from . util import live_server_setup -def test_setup(live_server): - live_server_setup(live_server) + # Should be the same as set_original_ignore_response() but with a little more whitespacing diff --git a/changedetectionio/tests/test_import.py b/changedetectionio/tests/test_import.py index 26cc6888e..899ff1bac 100644 --- a/changedetectionio/tests/test_import.py +++ b/changedetectionio/tests/test_import.py @@ -8,8 +8,8 @@ from flask import url_for from .util import live_server_setup, wait_for_all_checks -def test_setup(client, live_server, measure_memory_usage): - live_server_setup(live_server) +# def test_setup(client, live_server, measure_memory_usage): + # live_server_setup(live_server) # Setup on conftest per function def test_import(client, live_server, measure_memory_usage): # Give the endpoint time to spin up @@ -126,7 +126,7 @@ def test_import_distillio(client, live_server, measure_memory_usage): def test_import_custom_xlsx(client, live_server, measure_memory_usage): """Test can upload a excel spreadsheet and the watches are created correctly""" - #live_server_setup(live_server) + dirname = os.path.dirname(__file__) filename = os.path.join(dirname, 'import/spreadsheet.xlsx') @@ -175,7 +175,7 @@ def test_import_custom_xlsx(client, live_server, measure_memory_usage): def test_import_watchete_xlsx(client, live_server, measure_memory_usage): """Test can upload a excel spreadsheet and the watches are created correctly""" - #live_server_setup(live_server) + dirname = os.path.dirname(__file__) filename = os.path.join(dirname, 'import/spreadsheet.xlsx') with open(filename, 'rb') as f: diff --git a/changedetectionio/tests/test_jinja2.py b/changedetectionio/tests/test_jinja2.py index ca06b4671..71152943f 100644 --- a/changedetectionio/tests/test_jinja2.py +++ b/changedetectionio/tests/test_jinja2.py @@ -5,12 +5,12 @@ from flask import url_for from .util import live_server_setup, wait_for_all_checks -def test_setup(client, live_server, measure_memory_usage): - live_server_setup(live_server) +# def test_setup(client, live_server, measure_memory_usage): + # # live_server_setup(live_server) # Setup on conftest per function # If there was only a change in the whitespacing, then we shouldnt have a change detected def test_jinja2_in_url_query(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + # Add our URL to the import page test_url = url_for('test_return_query', _external=True) @@ -35,7 +35,7 @@ def test_jinja2_in_url_query(client, live_server, measure_memory_usage): # https://techtonics.medium.com/secure-templating-with-jinja2-understanding-ssti-and-jinja2-sandbox-environment-b956edd60456 def test_jinja2_security_url_query(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + # Add our URL to the import page test_url = url_for('test_return_query', _external=True) diff --git a/changedetectionio/tests/test_jsonpath_jq_selector.py b/changedetectionio/tests/test_jsonpath_jq_selector.py index 7f22ea039..380e6dea9 100644 --- a/changedetectionio/tests/test_jsonpath_jq_selector.py +++ b/changedetectionio/tests/test_jsonpath_jq_selector.py @@ -12,8 +12,7 @@ try: except ModuleNotFoundError: jq_support = False -def test_setup(live_server): - live_server_setup(live_server) + def test_unittest_inline_html_extract(): # So lets pretend that the JSON we want is inside some HTML diff --git a/changedetectionio/tests/test_live_preview.py b/changedetectionio/tests/test_live_preview.py index f8997692a..088e695f2 100644 --- a/changedetectionio/tests/test_live_preview.py +++ b/changedetectionio/tests/test_live_preview.py @@ -19,7 +19,7 @@ something to trigger
f.write(data) def test_content_filter_live_preview(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function set_response() test_url = url_for('test_endpoint', _external=True) diff --git a/changedetectionio/tests/test_nonrenderable_pages.py b/changedetectionio/tests/test_nonrenderable_pages.py index df2bef00e..e665cf038 100644 --- a/changedetectionio/tests/test_nonrenderable_pages.py +++ b/changedetectionio/tests/test_nonrenderable_pages.py @@ -27,7 +27,7 @@ def set_zero_byte_response(): def test_check_basic_change_detection_functionality(client, live_server, measure_memory_usage): set_original_response() - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # Add our URL to the import page res = client.post( diff --git a/changedetectionio/tests/test_notification.py b/changedetectionio/tests/test_notification.py index c7767b9e2..8640d2cca 100644 --- a/changedetectionio/tests/test_notification.py +++ b/changedetectionio/tests/test_notification.py @@ -17,13 +17,12 @@ from changedetectionio.notification import ( valid_notification_formats, ) -def test_setup(live_server): - live_server_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_check_notification(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + set_original_response() # Re 360 - new install should have defaults set @@ -285,7 +284,7 @@ def test_notification_validation(client, live_server, measure_memory_usage): def test_notification_custom_endpoint_and_jinja2(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + # test_endpoint - that sends the contents of a file # test_notification_endpoint - that takes a POST and writes it to file (test-datastore/notification.txt) @@ -371,7 +370,7 @@ def test_notification_custom_endpoint_and_jinja2(client, live_server, measure_me #2510 def test_global_send_test_notification(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + set_original_response() if os.path.isfile("test-datastore/notification.txt"): os.unlink("test-datastore/notification.txt") \ @@ -516,7 +515,7 @@ def _test_color_notifications(client, notification_body_token): def test_html_color_notifications(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + _test_color_notifications(client, '{{diff}}') _test_color_notifications(client, '{{diff_full}}') \ No newline at end of file diff --git a/changedetectionio/tests/test_notification_errors.py b/changedetectionio/tests/test_notification_errors.py index 3861df839..9b4ac7706 100644 --- a/changedetectionio/tests/test_notification_errors.py +++ b/changedetectionio/tests/test_notification_errors.py @@ -6,7 +6,7 @@ import logging def test_check_notification_error_handling(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function set_original_response() # Set a URL and fetch it, then set a notification URL which is going to give errors diff --git a/changedetectionio/tests/test_obfuscations.py b/changedetectionio/tests/test_obfuscations.py index 055e2dc89..9004f0fd3 100644 --- a/changedetectionio/tests/test_obfuscations.py +++ b/changedetectionio/tests/test_obfuscations.py @@ -20,7 +20,7 @@ def set_original_ignore_response(): def test_obfuscations(client, live_server, measure_memory_usage): set_original_ignore_response() - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function time.sleep(1) # Add our URL to the import page test_url = url_for('test_endpoint', _external=True) diff --git a/changedetectionio/tests/test_pdf.py b/changedetectionio/tests/test_pdf.py index 7dc32b5b9..5a8080b26 100644 --- a/changedetectionio/tests/test_pdf.py +++ b/changedetectionio/tests/test_pdf.py @@ -10,7 +10,7 @@ def test_fetch_pdf(client, live_server, measure_memory_usage): import shutil shutil.copy("tests/test.pdf", "test-datastore/endpoint-test.pdf") - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function test_url = url_for('test_pdf_endpoint', _external=True) # Add our URL to the import page res = client.post( diff --git a/changedetectionio/tests/test_preview_endpoints.py b/changedetectionio/tests/test_preview_endpoints.py index 3cb23b7c4..ada52ed44 100644 --- a/changedetectionio/tests/test_preview_endpoints.py +++ b/changedetectionio/tests/test_preview_endpoints.py @@ -10,7 +10,7 @@ def test_fetch_pdf(client, live_server, measure_memory_usage): import shutil shutil.copy("tests/test.pdf", "test-datastore/endpoint-test.pdf") - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function test_url = url_for('test_pdf_endpoint', _external=True) # Add our URL to the import page res = client.post( diff --git a/changedetectionio/tests/test_request.py b/changedetectionio/tests/test_request.py index 0b228bfd3..85b006338 100644 --- a/changedetectionio/tests/test_request.py +++ b/changedetectionio/tests/test_request.py @@ -4,8 +4,7 @@ import time from flask import url_for from . util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks, extract_UUID_from_client -def test_setup(live_server): - live_server_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) @@ -258,7 +257,7 @@ def test_method_in_request(client, live_server, measure_memory_usage): # Re #2408 - user-agent override test, also should handle case-insensitive header deduplication def test_ua_global_override(client, live_server, measure_memory_usage): - # live_server_setup(live_server) + ## live_server_setup(live_server) # Setup on conftest per function test_url = url_for('test_headers', _external=True) res = client.post( @@ -313,7 +312,7 @@ def test_ua_global_override(client, live_server, measure_memory_usage): assert b'Deleted' in res.data def test_headers_textfile_in_request(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + # Add our URL to the import page webdriver_ua = "Hello fancy webdriver UA 1.0" @@ -426,7 +425,7 @@ def test_headers_textfile_in_request(client, live_server, measure_memory_usage): assert b'Deleted' in res.data def test_headers_validation(client, live_server): - #live_server_setup(live_server) + test_url = url_for('test_headers', _external=True) res = client.post( diff --git a/changedetectionio/tests/test_restock_itemprop.py b/changedetectionio/tests/test_restock_itemprop.py index 73454cd84..13cab44e4 100644 --- a/changedetectionio/tests/test_restock_itemprop.py +++ b/changedetectionio/tests/test_restock_itemprop.py @@ -44,13 +44,13 @@ def set_original_response(props_markup='', price="121.95"): -def test_setup(client, live_server): +# def test_setup(client, live_server): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function def test_restock_itemprop_basic(client, live_server): - #live_server_setup(live_server) + test_url = url_for('test_endpoint', _external=True) @@ -89,7 +89,7 @@ def test_restock_itemprop_basic(client, live_server): assert b'Deleted' in res.data def test_itemprop_price_change(client, live_server): - #live_server_setup(live_server) + # Out of the box 'Follow price changes' should be ON test_url = url_for('test_endpoint', _external=True) @@ -214,7 +214,7 @@ def _run_test_minmax_limit(client, extra_watch_edit_form): def test_restock_itemprop_minmax(client, live_server): - #live_server_setup(live_server) + extras = { "restock_settings-follow_price_changes": "y", "restock_settings-price_change_min": 900.0, @@ -223,7 +223,7 @@ def test_restock_itemprop_minmax(client, live_server): _run_test_minmax_limit(client, extra_watch_edit_form=extras) def test_restock_itemprop_with_tag(client, live_server): - #live_server_setup(live_server) + res = client.post( url_for("tags.form_tag_add"), @@ -252,7 +252,7 @@ def test_restock_itemprop_with_tag(client, live_server): def test_itemprop_percent_threshold(client, live_server): - #live_server_setup(live_server) + res = client.get(url_for("ui.form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data @@ -319,7 +319,7 @@ def test_itemprop_percent_threshold(client, live_server): def test_change_with_notification_values(client, live_server): - #live_server_setup(live_server) + if os.path.isfile("test-datastore/notification.txt"): os.unlink("test-datastore/notification.txt") @@ -387,7 +387,7 @@ def test_change_with_notification_values(client, live_server): def test_data_sanity(client, live_server): - #live_server_setup(live_server) + res = client.get(url_for("ui.form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data @@ -437,7 +437,7 @@ def test_data_sanity(client, live_server): # All examples should give a prive of 666.66 def test_special_prop_examples(client, live_server): import glob - #live_server_setup(live_server) + test_url = url_for('test_endpoint', _external=True) check_path = os.path.join(os.path.dirname(__file__), "itemprop_test_examples", "*.txt") diff --git a/changedetectionio/tests/test_rss.py b/changedetectionio/tests/test_rss.py index 5701f6905..847c9fade 100644 --- a/changedetectionio/tests/test_rss.py +++ b/changedetectionio/tests/test_rss.py @@ -65,11 +65,11 @@ def set_html_content(content): with open("test-datastore/endpoint-content.txt", "wb") as f: f.write(test_return_data.encode('utf-8')) -def test_setup(client, live_server, measure_memory_usage): - live_server_setup(live_server) +# def test_setup(client, live_server, measure_memory_usage): + # live_server_setup(live_server) # Setup on conftest per function def test_rss_and_token(client, live_server, measure_memory_usage): - # live_server_setup(live_server) + # # live_server_setup(live_server) # Setup on conftest per function set_original_response() rss_token = extract_rss_token_from_UI(client) @@ -107,7 +107,7 @@ def test_rss_and_token(client, live_server, measure_memory_usage): client.get(url_for("ui.form_delete", uuid="all"), follow_redirects=True) def test_basic_cdata_rss_markup(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + set_original_cdata_xml() @@ -135,7 +135,7 @@ def test_basic_cdata_rss_markup(client, live_server, measure_memory_usage): res = client.get(url_for("ui.form_delete", uuid="all"), follow_redirects=True) def test_rss_xpath_filtering(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + set_original_cdata_xml() @@ -191,7 +191,7 @@ def test_rss_bad_chars_breaking(client, live_server): Otherwise feedgen should support regular unicode """ - #live_server_setup(live_server) + with open("test-datastore/endpoint-content.txt", "w") as f: ten_kb_string = "A" * 10_000 diff --git a/changedetectionio/tests/test_scheduler.py b/changedetectionio/tests/test_scheduler.py index caacc3ad9..51610d60e 100644 --- a/changedetectionio/tests/test_scheduler.py +++ b/changedetectionio/tests/test_scheduler.py @@ -6,11 +6,11 @@ from zoneinfo import ZoneInfo from flask import url_for from .util import live_server_setup, wait_for_all_checks, extract_UUID_from_client -def test_setup(client, live_server): - live_server_setup(live_server) +# def test_setup(client, live_server): + # live_server_setup(live_server) # Setup on conftest per function def test_check_basic_scheduler_functionality(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] test_url = url_for('test_random_content_endpoint', _external=True) @@ -92,7 +92,7 @@ def test_check_basic_scheduler_functionality(client, live_server, measure_memory def test_check_basic_global_scheduler_functionality(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] test_url = url_for('test_random_content_endpoint', _external=True) diff --git a/changedetectionio/tests/test_search.py b/changedetectionio/tests/test_search.py index 1668eaab6..eb6f0ee9f 100644 --- a/changedetectionio/tests/test_search.py +++ b/changedetectionio/tests/test_search.py @@ -2,11 +2,10 @@ from flask import url_for from .util import set_original_response, set_modified_response, live_server_setup import time -def test_setup(live_server): - live_server_setup(live_server) + def test_basic_search(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + urls = ['https://localhost:12300?first-result=1', 'https://localhost:5000?second-result=1' @@ -39,7 +38,7 @@ def test_basic_search(client, live_server, measure_memory_usage): def test_search_in_tag_limit(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + urls = ['https://localhost:12300?first-result=1 tag-one', 'https://localhost:5000?second-result=1 tag-two' diff --git a/changedetectionio/tests/test_security.py b/changedetectionio/tests/test_security.py index 00902bfc4..495e12a83 100644 --- a/changedetectionio/tests/test_security.py +++ b/changedetectionio/tests/test_security.py @@ -5,11 +5,11 @@ from .util import live_server_setup, wait_for_all_checks from .. import strtobool -def test_setup(client, live_server, measure_memory_usage): - live_server_setup(live_server) +# def test_setup(client, live_server, measure_memory_usage): + # live_server_setup(live_server) # Setup on conftest per function def test_bad_access(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + res = client.post( url_for("imports.import_page"), data={"urls": 'https://localhost'}, @@ -89,7 +89,7 @@ def _runner_test_various_file_slash(client, file_uri): assert b'Deleted' in res.data def test_file_slash_access(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + # file: is NOT permitted by default, so it will be caught by ALLOW_FILE_URI check @@ -99,7 +99,7 @@ def test_file_slash_access(client, live_server, measure_memory_usage): _runner_test_various_file_slash(client, file_uri=f"file:{test_file_path}") # CVE-2024-56509 def test_xss(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + from changedetectionio.notification import ( default_notification_format ) diff --git a/changedetectionio/tests/test_share_watch.py b/changedetectionio/tests/test_share_watch.py index 004563174..09e3f35d3 100644 --- a/changedetectionio/tests/test_share_watch.py +++ b/changedetectionio/tests/test_share_watch.py @@ -11,7 +11,7 @@ sleep_time_for_fetch_thread = 3 def test_share_watch(client, live_server, measure_memory_usage): set_original_response() - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function test_url = url_for('test_endpoint', _external=True) include_filters = ".nice-filter" diff --git a/changedetectionio/tests/test_source.py b/changedetectionio/tests/test_source.py index 809b1909a..992314c1f 100644 --- a/changedetectionio/tests/test_source.py +++ b/changedetectionio/tests/test_source.py @@ -7,8 +7,7 @@ from .util import set_original_response, set_modified_response, live_server_setu sleep_time_for_fetch_thread = 3 -def test_setup(live_server): - live_server_setup(live_server) + def test_check_basic_change_detection_functionality_source(client, live_server, measure_memory_usage): set_original_response() diff --git a/changedetectionio/tests/test_trigger.py b/changedetectionio/tests/test_trigger.py index dc18c1a5a..0df5ec3b5 100644 --- a/changedetectionio/tests/test_trigger.py +++ b/changedetectionio/tests/test_trigger.py @@ -57,7 +57,7 @@ def set_modified_with_trigger_text_response(): def test_trigger_functionality(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function trigger_text = "Add to cart" set_original_ignore_response() diff --git a/changedetectionio/tests/test_trigger_regex.py b/changedetectionio/tests/test_trigger_regex.py index 62c6acb7b..25253f216 100644 --- a/changedetectionio/tests/test_trigger_regex.py +++ b/changedetectionio/tests/test_trigger_regex.py @@ -24,7 +24,7 @@ def set_original_ignore_response(): def test_trigger_regex_functionality(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function set_original_ignore_response() diff --git a/changedetectionio/tests/test_trigger_regex_with_filter.py b/changedetectionio/tests/test_trigger_regex_with_filter.py index bf69da9d8..a78b8fc46 100644 --- a/changedetectionio/tests/test_trigger_regex_with_filter.py +++ b/changedetectionio/tests/test_trigger_regex_with_filter.py @@ -24,7 +24,7 @@ def set_original_ignore_response(): def test_trigger_regex_functionality_with_filter(client, live_server, measure_memory_usage): - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function sleep_time_for_fetch_thread = 3 set_original_ignore_response() diff --git a/changedetectionio/tests/test_ui.py b/changedetectionio/tests/test_ui.py index 743b70b5b..aec1ff601 100644 --- a/changedetectionio/tests/test_ui.py +++ b/changedetectionio/tests/test_ui.py @@ -6,7 +6,7 @@ from .util import set_original_response, set_modified_response, live_server_setu def test_checkbox_open_diff_in_new_tab(client, live_server): set_original_response() - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function # Add our URL to the import page res = client.post( diff --git a/changedetectionio/tests/test_unique_lines.py b/changedetectionio/tests/test_unique_lines.py index f3f70dc37..b4829e62e 100644 --- a/changedetectionio/tests/test_unique_lines.py +++ b/changedetectionio/tests/test_unique_lines.py @@ -68,11 +68,11 @@ def set_modified_with_trigger_text_response(): with open("test-datastore/endpoint-content.txt", "w") as f: f.write(test_return_data) -def test_setup(client, live_server, measure_memory_usage): - live_server_setup(live_server) +# def test_setup(client, live_server, measure_memory_usage): + # live_server_setup(live_server) # Setup on conftest per function def test_unique_lines_functionality(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + set_original_ignore_response() @@ -121,7 +121,7 @@ def test_unique_lines_functionality(client, live_server, measure_memory_usage): assert b'Deleted' in res.data def test_sort_lines_functionality(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + set_modified_swapped_lines_with_extra_text_for_sorting() @@ -171,7 +171,7 @@ def test_sort_lines_functionality(client, live_server, measure_memory_usage): def test_extra_filters(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + set_original_ignore_response() diff --git a/changedetectionio/tests/test_watch_fields_storage.py b/changedetectionio/tests/test_watch_fields_storage.py index 8765a51f1..506722fe2 100644 --- a/changedetectionio/tests/test_watch_fields_storage.py +++ b/changedetectionio/tests/test_watch_fields_storage.py @@ -6,7 +6,7 @@ from . util import set_original_response, set_modified_response, live_server_set def test_check_watch_field_storage(client, live_server, measure_memory_usage): set_original_response() - live_server_setup(live_server) + # live_server_setup(live_server) # Setup on conftest per function test_url = "http://somerandomsitewewatch.com" diff --git a/changedetectionio/tests/test_xpath_selector.py b/changedetectionio/tests/test_xpath_selector.py index b3d0350eb..fbdf201c6 100644 --- a/changedetectionio/tests/test_xpath_selector.py +++ b/changedetectionio/tests/test_xpath_selector.py @@ -7,8 +7,7 @@ from .util import live_server_setup, wait_for_all_checks from ..html_tools import * -def test_setup(live_server): - live_server_setup(live_server) + def set_original_response(): @@ -256,7 +255,7 @@ def test_xpath23_prefix_validation(client, live_server, measure_memory_usage): assert b'Deleted' in res.data def test_xpath1_lxml(client, live_server, measure_memory_usage): - #live_server_setup(live_server) + d = ''' @@ -380,7 +379,7 @@ def test_check_with_prefix_include_filters(client, live_server, measure_memory_u def test_various_rules(client, live_server, measure_memory_usage): # Just check these don't error - # live_server_setup(live_server) + ## live_server_setup(live_server) # Setup on conftest per function with open("test-datastore/endpoint-content.txt", "w") as f: f.write(""" diff --git a/changedetectionio/tests/util.py b/changedetectionio/tests/util.py index a256fac0d..08bfaaa16 100644 --- a/changedetectionio/tests/util.py +++ b/changedetectionio/tests/util.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +from operator import truediv from flask import make_response, request from flask import url_for @@ -162,8 +163,13 @@ def wait_for_all_checks(client=None): empty_since = None attempt += 1 + time.sleep(0.2) -def live_server_setup(live_server): +# Replaced by new_live_server_setup and calling per function scope in conftest.py +def live_server_setup(live_server): + return True + +def new_live_server_setup(live_server): @live_server.app.route('/test-random-content-endpoint') def test_random_content_endpoint(): diff --git a/changedetectionio/tests/visualselector/test_fetch_data.py b/changedetectionio/tests/visualselector/test_fetch_data.py index 3f983a987..c476f7db2 100644 --- a/changedetectionio/tests/visualselector/test_fetch_data.py +++ b/changedetectionio/tests/visualselector/test_fetch_data.py @@ -4,8 +4,8 @@ import os from flask import url_for from ..util import live_server_setup, wait_for_all_checks -def test_setup(client, live_server): - live_server_setup(live_server) +# def test_setup(client, live_server): + # live_server_setup(live_server) # Setup on conftest per function # Add a site in paused mode, add an invalid filter, we should still have visual selector data ready