test tweaks

This commit is contained in:
dgtlmoon
2025-06-03 09:06:19 +02:00
parent cf01015601
commit 6949a09aab
70 changed files with 178 additions and 171 deletions
+18
View File
@@ -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."""
@@ -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)
@@ -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(
@@ -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)
@@ -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"
@@ -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"
@@ -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
@@ -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(
@@ -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(
@@ -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
@@ -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', '')}"
@@ -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')
@@ -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
@@ -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.
@@ -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)
+6 -6
View File
@@ -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
@@ -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
+1 -1
View File
@@ -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 = {}
+1 -1
View File
@@ -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'
+1 -1
View File
@@ -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
@@ -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 = """
<html>
<head>
+1 -1
View File
@@ -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(
+1 -1
View File
@@ -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()
@@ -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)
@@ -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()
+1 -1
View File
@@ -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("<html><body>Some content</body></html>")
+5 -5
View File
@@ -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 = """<html>
<body>
@@ -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("""<html>
+3 -4
View File
@@ -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 = """<html>
@@ -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"
@@ -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= """<!DOCTYPE html>
@@ -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 = ["""
+1 -2
View File
@@ -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():
@@ -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)
+1 -1
View File
@@ -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(
@@ -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)
@@ -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)
@@ -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
+10 -10
View File
@@ -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 = """<html>
@@ -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)
@@ -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)
+1 -1
View File
@@ -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(
@@ -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
+3 -4
View File
@@ -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/')
@@ -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 = """<html>
@@ -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():
@@ -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
+4 -4
View File
@@ -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:
+4 -4
View File
@@ -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)
@@ -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
+1 -1
View File
@@ -19,7 +19,7 @@ something to trigger<br>
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)
@@ -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(
+5 -6
View File
@@ -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}}')
@@ -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
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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(
@@ -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(
+4 -5
View File
@@ -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(
@@ -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")
+6 -6
View File
@@ -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
+4 -4
View File
@@ -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)
+3 -4
View File
@@ -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'
+5 -5
View File
@@ -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
)
+1 -1
View File
@@ -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"
+1 -2
View File
@@ -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()
+1 -1
View File
@@ -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()
@@ -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()
@@ -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()
+1 -1
View File
@@ -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(
+5 -5
View File
@@ -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()
@@ -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"
@@ -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 = '''<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
@@ -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("""<html>
<body>
+7 -1
View File
@@ -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():
@@ -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