repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
changedetection.io | changedetectionio/tests/test_ignorehyperlinks.py | .py | #!/usr/bin/env python3
"""Test suite for the render/not render anchor tag content functionality"""
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks, delete_all_watches
import os
def set_original_ignore_response(datastore_path):
test_return_data = """<html>
<bo... | 120 | 3,762 |
changedetection.io | changedetectionio/tests/__init__.py | .py | """Tests for the app."""
| 3 | 26 |
changedetection.io | changedetectionio/tests/test_auth.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
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, datastore_path):
# live_server_setup(live_server) # Setup on conftest per... | 34 | 1,230 |
changedetection.io | changedetectionio/tests/test_extract_csv.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from urllib.request import urlopen
from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks
import os
def test_check_extract_text_from_diff(client, live_server, measure_memory_usage, datastore_path):
import ... | 74 | 2,515 |
changedetection.io | changedetectionio/tests/test_search.py | .py | from flask import url_for
from .util import set_original_response, set_modified_response, live_server_setup
import time
def test_basic_search(client, live_server, measure_memory_usage, datastore_path):
urls = ['https://localhost:12300?first-result=1',
'https://localhost:5000?second-result=1'
... | 74 | 2,513 |
changedetection.io | changedetectionio/tests/test_llm_preview.py | .py | #!/usr/bin/env python3
"""
Integration tests: /edit/<uuid>/preview-rendered returns llm_evaluation when
llm_intent is submitted alongside the filter form data.
These tests verify the full backend path:
JS POSTs llm_intent → prepare_filter_prevew() applies it to tmp_watch
→ preview_extract() is called → llm_evaluat... | 233 | 8,651 |
changedetection.io | changedetectionio/tests/test_trigger_regex.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks, delete_all_watches
import os
def set_original_ignore_response(datastore_path):
test_return_data = """<html>
<body>
Some initial text<br>
<p>Which is across multiple lines</p>
... | 77 | 2,519 |
changedetection.io | changedetectionio/tests/test_datastore_isolation.py | .py | #!/usr/bin/env python3
"""Test to verify client and live_server share the same datastore"""
def test_client_and_live_server_share_datastore(client, live_server):
"""Verify that client and live_server use the same app and datastore."""
# They should be the SAME object
assert client.application is live_serv... | 20 | 959 |
changedetection.io | changedetectionio/tests/test_share_watch.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from urllib.request import urlopen
from .util import set_original_response, set_modified_response, live_server_setup, delete_all_watches
import re
def test_share_watch(client, live_server, measure_memory_usage, datastore_path):
set_original_response(dat... | 75 | 2,586 |
changedetection.io | changedetectionio/tests/test_xpath_default_namespace.py | .py | #!/usr/bin/env python3
"""
Unit tests for XPath default namespace handling in RSS/Atom feeds.
Tests the fix for issue where //title/text() returns empty on feeds with default namespaces.
Real-world test data from https://github.com/microsoft/PowerToys/releases.atom
"""
import sys
import os
import pytest
sys.path.ins... | 154 | 6,802 |
changedetection.io | changedetectionio/tests/test_extract_regex.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks, delete_all_watches
import os
from ..html_tools import *
def set_original_response(datastore_path):
test_return_data = """<html>
<body>
Some initial text<br>
<p>Which is across ... | 637 | 22,159 |
changedetection.io | changedetectionio/tests/test_obfuscations.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks
import os
def set_original_ignore_response(datastore_path):
test_return_data = """<html>
<body>
<span>The price is</span><span>$<!-- -->90<!-- -->.<!-- -->74</span>
</body>
... | 40 | 1,033 |
changedetection.io | changedetectionio/tests/test_notification_errors.py | .py | import os
import time
from flask import url_for
from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks, delete_all_watches
import logging
def test_check_notification_error_handling(client, live_server, measure_memory_usage, datastore_path):
# live_server_setup(live_... | 85 | 3,074 |
changedetection.io | changedetectionio/tests/test_security.py | .py | import io
import os
import re
import time
import pytest
from flask import url_for
from zipfile import ZipFile, ZIP_DEFLATED
from changedetectionio.tests.util import set_modified_response
from .util import live_server_setup, wait_for_all_checks, delete_all_watches
from .. import strtobool
def set_original_response(d... | 1,009 | 42,079 |
changedetection.io | changedetectionio/tests/test_backup.py | .py | #!/usr/bin/env python3
from .util import set_original_response, live_server_setup, wait_for_all_checks
from flask import url_for
import io
from zipfile import ZipFile, ZIP_DEFLATED
import re
import time
from changedetectionio.model import Watch, Tag
def test_backup(client, live_server, measure_memory_usage, datastor... | 261 | 10,639 |
changedetection.io | changedetectionio/tests/test_api_openapi.py | .py | #!/usr/bin/env python3
"""
OpenAPI validation tests for ChangeDetection.io API
This test file specifically verifies that OpenAPI validation is working correctly
by testing various scenarios that should trigger validation errors.
"""
import time
import json
from flask import url_for
from .util import live_server_setup... | 256 | 11,397 |
changedetection.io | changedetectionio/tests/test_ignore_regex_text.py | .py | #!/usr/bin/env python3
from . util import live_server_setup
from changedetectionio import html_tools
# Unit test of the stripper
# Always we are dealing in utf-8
def test_strip_regex_text_func():
test_content = """
but sometimes we want to remove the lines.
but 1 lines
skip 5 lines
really? ... | 88 | 3,469 |
changedetection.io | changedetectionio/tests/test_watch_edited_flag.py | .py | #!/usr/bin/env python3
"""
Test the watch edited flag functionality.
This tests the private __watch_was_edited flag that tracks when writable
watch fields are modified, which prevents skipping reprocessing when the
watch configuration has changed.
"""
import os
import time
from flask import url_for
from .util import ... | 247 | 9,969 |
changedetection.io | changedetectionio/tests/test_filter_exist_changes.py | .py | #!/usr/bin/env python3
# https://www.reddit.com/r/selfhosted/comments/wa89kp/comment/ii3a4g7/?context=3
import os
import time
from flask import url_for
from .util import set_original_response, live_server_setup, wait_for_notification_endpoint_output
from changedetectionio.model import App
def set_response_without_fi... | 125 | 5,009 |
changedetection.io | changedetectionio/tests/test_ignorewhitespace.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
import os
from .util import live_server_setup, delete_all_watches, wait_for_all_checks
# Should be the same as set_original_ignore_response(datastore_path=datastore_path) but with a little more whitespacing
def set_original_ignore_response_but_with_whites... | 89 | 2,541 |
changedetection.io | changedetectionio/tests/test_import.py | .py | #!/usr/bin/env python3
import io
import os
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks, delete_all_watches
# def test_setup(client, live_server, measure_memory_usage, datastore_path):
# live_server_setup(live_server) # Setup on conftest per function
def test_i... | 299 | 10,651 |
changedetection.io | changedetectionio/tests/test_live_preview.py | .py | #!/usr/bin/env python3
from flask import url_for
from changedetectionio.tests.util import live_server_setup, wait_for_all_checks, extract_UUID_from_client, delete_all_watches
import os
def set_response(datastore_path):
data = """<html>
<body>Awesome, you made it<br>
yeah the socks request worked<br>
some... | 159 | 5,890 |
changedetection.io | changedetectionio/tests/test_rss_reader_mode.py | .py | #!/usr/bin/env python3
import time
import os
from flask import url_for
from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks, extract_rss_token_from_UI, \
extract_UUID_from_client, delete_all_watches
def set_xmlns_purl_content(datastore_path, extra=""):
data=f... | 179 | 8,574 |
changedetection.io | changedetectionio/tests/test_ignore.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks
from changedetectionio import html_tools
from . util import extract_UUID_from_client
import os
def set_original_ignore_response(datastore_path):
test_return_data = """<html>
<body>
So... | 90 | 3,135 |
changedetection.io | changedetectionio/tests/test_i18n.py | .py | #!/usr/bin/env python3
from flask import url_for
from .util import live_server_setup, wait_for_all_checks
def test_zh_TW(client, live_server, measure_memory_usage, datastore_path):
import time
test_url = url_for('test_endpoint', _external=True)
# Be sure we got a session cookie
res = client.get(url_... | 743 | 32,727 |
changedetection.io | changedetectionio/tests/test_request.py | .py | import json
import os
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, delete_all_watches
# Hard to just add more live server URLs when one test is already running (I think)
# So we add our test he... | 430 | 16,118 |
changedetection.io | changedetectionio/tests/test_ignorestatuscode.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks
import os
def set_original_response(datastore_path):
test_return_data = """<html>
<body>
Some initial text<br>
<p>Which is across multiple lines</p>
<br>
So let's se... | 141 | 4,847 |
changedetection.io | changedetectionio/tests/test_api_security.py | .py | #!/usr/bin/env python3
"""
Comprehensive security and edge case tests for the API.
Tests critical areas that were identified as gaps in the existing test suite.
"""
import time
import json
import threading
import uuid as uuid_module
from flask import url_for
from .util import live_server_setup, wait_for_all_checks, wa... | 880 | 32,984 |
changedetection.io | changedetectionio/tests/test_xpath_selector_unit.py | .py | import sys
import os
import pytest
from changedetectionio import html_tools
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# test generation guide.
# 1. Do not include encoding in the xml declaration if the test object is a str type.
# 2. Always paraphrase test.
hotels = """
<hotel>... | 323 | 16,347 |
changedetection.io | changedetectionio/tests/test_ui.py | .py | #!/usr/bin/env python3
from flask import url_for
from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks, delete_all_watches
from ..forms import REQUIRE_ATLEAST_ONE_TIME_PART_WHEN_NOT_GLOBAL_DEFAULT, REQUIRE_ATLEAST_ONE_TIME_PART_MESSAGE_DEFAULT
def test_recheck_time_fi... | 292 | 10,438 |
changedetection.io | changedetectionio/tests/test_queue_ui.py | .py | """
Tests for the queue inspection UI (blueprint/ui/queue.py).
Strategy: shut down all workers, pause the scheduler, then push synthetic
UUIDs directly into update_q. Synthetic UUIDs are immune to scheduler
interference. The HTTP test client + live_server share the same process,
so update_q is a single instance.
"""
... | 289 | 12,284 |
changedetection.io | changedetectionio/tests/test_css_selector.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks
import os
from ..html_tools import *
def set_original_response(datastore_path):
test_return_data = """<html>
<body>
Some initial text<br>
<p>Which is across multiple lines</p>
... | 236 | 7,447 |
changedetection.io | changedetectionio/tests/test_group.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks, extract_rss_token_from_UI, get_UUID_for_tag_name, extract_UUID_from_client, delete_all_watches
import os
from ..store import ChangeDetectionStore
# def test_setup(client, live_server, measure_memor... | 619 | 22,637 |
changedetection.io | changedetectionio/tests/test_watch_fields_storage.py | .py | import time
from flask import url_for
from urllib.request import urlopen
from . util import set_original_response, set_modified_response, live_server_setup
def test_check_watch_field_storage(client, live_server, measure_memory_usage, datastore_path):
set_original_response(datastore_path=datastore_path)
# liv... | 55 | 1,951 |
changedetection.io | changedetectionio/tests/test_api_notifications.py | .py | #!/usr/bin/env python3
from flask import url_for
from .util import live_server_setup
import json
def test_api_notifications_crud(client, live_server, measure_memory_usage, datastore_path):
# live_server_setup(live_server) # Setup on conftest per function
api_key = live_server.app.config['DATASTORE'].data['set... | 108 | 3,767 |
changedetection.io | changedetectionio/tests/test_rss.py | .py | #!/usr/bin/env python3
import os
import time
from flask import url_for
from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks, extract_rss_token_from_UI, \
extract_UUID_from_client, delete_all_watches
from loguru import logger
from ..blueprint.rss import RSS_FORMAT_TY... | 357 | 14,005 |
changedetection.io | changedetectionio/tests/test_restock_itemprop.py | .py | #!/usr/bin/env python3
import os
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks, wait_for_notification_endpoint_output, extract_UUID_from_client, delete_all_watches
from ..notification import default_notification_format
instock_props = [
# LD+JSON with non-standard ... | 638 | 29,501 |
changedetection.io | changedetectionio/tests/test_api_search.py | .py | from copy import copy
from flask import url_for
import json
import time
from .util import live_server_setup, wait_for_all_checks
def test_api_search(client, live_server, measure_memory_usage, datastore_path):
# live_server_setup(live_server) # Setup on conftest per function
api_key = live_server.app.config['... | 102 | 3,780 |
changedetection.io | changedetectionio/tests/test_jinja2.py | .py | #!/usr/bin/env python3
import time
import arrow
from flask import url_for
from .util import live_server_setup, wait_for_all_checks
from ..jinja2_custom import render
# def test_setup(client, live_server, measure_memory_usage, datastore_path):
# # live_server_setup(live_server) # Setup on conftest per function
#... | 321 | 12,022 |
changedetection.io | changedetectionio/tests/test_errorhandling.py | .py | #!/usr/bin/env python3
import time
import os
from flask import url_for
from .util import live_server_setup, wait_for_all_checks, delete_all_watches
def _runner_test_http_errors(client, live_server, http_code, expected_text, datastore_path):
with open(os.path.join(datastore_path, "endpoint-content.txt"), "w")... | 139 | 4,996 |
changedetection.io | changedetectionio/tests/test_filter_failure_notification.py | .py | import os
import time
from flask import url_for
from .util import set_original_response, wait_for_all_checks, wait_for_notification_endpoint_output, delete_all_watches
from ..notification import valid_notification_formats
def set_response_with_filter(datastore_path):
test_return_data = """<html>
<body>
... | 206 | 9,415 |
changedetection.io | changedetectionio/tests/test_api_notification_urls_validation.py | .py | #!/usr/bin/env python3
"""
Test notification_urls validation in Watch and Tag API endpoints.
Ensures that invalid AppRise URLs are rejected when setting notification_urls.
Valid AppRise notification URLs use specific protocols like:
- posts://example.com - POST to HTTP endpoint
- gets://example.com - GET to HTTP endp... | 167 | 7,377 |
changedetection.io | changedetectionio/tests/test_element_removal.py | .py | #!/usr/bin/env python3
import time
import os
from flask import url_for
from ..html_tools import *
from .util import live_server_setup, wait_for_all_checks, delete_all_watches
def set_response_with_multiple_index(datastore_path):
data= """<!DOCTYPE html>
<html>
<body>
<!-- NOTE!! CHROME WILL ADD TBODY HERE I... | 292 | 8,457 |
changedetection.io | changedetectionio/tests/test_notification.py | .py | import json
import os
import time
import re
from flask import url_for
from loguru import logger
from .util import set_original_response, set_modified_response, set_more_modified_response, live_server_setup, wait_for_all_checks, wait_for_notification_endpoint_output
from . util import extract_UUID_from_client
import l... | 860 | 38,957 |
changedetection.io | changedetectionio/tests/test_rss_group.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks, wait_for_watch_history, extract_rss_token_from_UI, get_UUID_for_tag_name, delete_all_watches
import os
def set_original_response(datastore_path):
test_return_data = """<html>
<body>
... | 263 | 8,580 |
changedetection.io | changedetectionio/tests/test_automatic_follow_ldjson_price.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from .util import live_server_setup, extract_UUID_from_client, wait_for_all_checks, delete_all_watches
import os
def set_response_with_ldjson(datastore_path):
test_return_data = """<html>
<body>
Some initial text<br>
<p>Which is across... | 237 | 9,565 |
changedetection.io | changedetectionio/tests/test_basic_socketio.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from .util import (
set_original_response,
set_modified_response,
live_server_setup,
wait_for_all_checks, delete_all_watches
)
from loguru import logger
def run_socketio_watch_update_test(client, live_server, password_mode="", datastore_path... | 138 | 5,063 |
changedetection.io | changedetectionio/tests/test_html_to_text.py | .py | #!/usr/bin/env python3
"""Test suite for the method to extract text from an html string"""
from ..html_tools import html_to_text
def test_html_to_text_func():
test_html = """<html>
<body>
Some initial text<br>
<p>Which is across multiple lines</p>
<a href="/first_link"> More Text </a>
<... | 39 | 1,280 |
changedetection.io | changedetectionio/tests/test_settings_notifications_page.py | .py | #!/usr/bin/env python3
"""
Tests for the /settings/notifications page (separated from the main /settings
form in 2026). The notification config lives at
datastore.data['settings']['application']['notification_*']
and is now edited via its own form + route. The main settings page must NOT
clobber those values when a... | 228 | 10,666 |
changedetection.io | changedetectionio/tests/test_unique_lines.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from .util import live_server_setup, wait_for_all_checks, delete_all_watches
import os
def set_original_ignore_response(datastore_path):
test_return_data = """<html>
<body>
<p>Some initial text</p>
<p>Which is across multiple lines</p>
... | 206 | 6,821 |
changedetection.io | changedetectionio/tests/test_history_consistency.py | .py | #!/usr/bin/env python3
import time
import os
import json
from flask import url_for
from loguru import logger
from .. import strtobool
from .util import wait_for_all_checks, delete_all_watches
import brotli
def test_consistent_history(client, live_server, measure_memory_usage, datastore_path):
uuids = set()
... | 275 | 12,683 |
changedetection.io | changedetectionio/tests/test_tag_url_match.py | .py | #!/usr/bin/env python3
"""
Integration tests for auto-applying tags to watches by URL pattern matching.
Verifies:
- A tag with url_match_pattern shows on the watch overview list (via get_all_tags_for_watch)
- The auto-applied tag appears on the watch edit page
- A watch whose URL does NOT match the pattern does not... | 189 | 8,142 |
changedetection.io | changedetectionio/tests/test_rss_tag_token.py | .py | import os
import pytest
from flask import url_for
from .util import set_original_response, live_server_setup, wait_for_all_checks, extract_rss_token_from_UI, set_modified_response
def test_rss_tag_feed_ignores_security_token(client, live_server, datastore_path):
# Enable password authentication via settings endpoi... | 52 | 2,019 |
changedetection.io | changedetectionio/tests/conftest.py | .py | #!/usr/bin/env python3
import psutil
import time
from threading import Thread
import multiprocessing
import pytest
import arrow
from changedetectionio import store
import os
import sys
# CRITICAL: Set short timeout for tests to prevent 45-second hangs
# When test server is slow/unresponsive, workers fail fast instead... | 498 | 18,461 |
changedetection.io | changedetectionio/tests/proxy_socks5/test_socks5_proxy.py | .py | #!/usr/bin/env python3
import json
import os
from flask import url_for
from changedetectionio.tests.util import live_server_setup, wait_for_all_checks, extract_UUID_from_client, delete_all_watches
def set_response(datastore_path):
import time
data = """<html>
<body>
<h1>Awesome, you made it</h1>
... | 103 | 3,341 |
changedetection.io | changedetectionio/tests/proxy_socks5/test_socks5_proxy_sources.py | .py | #!/usr/bin/env python3
import os
from flask import url_for
from changedetectionio.tests.util import live_server_setup, wait_for_all_checks
def set_response(datastore_path):
import time
data = """<html>
<body>
<h1>Awesome, you made it</h1>
yeah the socks request worked
</body>
</html... | 70 | 2,491 |
changedetection.io | changedetectionio/tests/fetchers/test_custom_js_before_content.py | .py | import os
from flask import url_for
from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client
def test_execute_custom_js(client, live_server, measure_memory_usage, datastore_path):
# live_server_setup(live_server) # Setup on conftest per function
assert os.getenv('PLAYWRIGHT_DRIVER_... | 57 | 2,167 |
changedetection.io | changedetectionio/tests/fetchers/test_content.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
import os
from ..util import live_server_setup, wait_for_all_checks
import logging
# Requires playwright to be installed
def test_fetch_webdriver_content(client, live_server, measure_memory_usage, datastore_path):
# live_server_setup(live_server) # Se... | 86 | 2,807 |
changedetection.io | changedetectionio/tests/custom_browser_url/test_custom_browser_url.py | .py | #!/usr/bin/env python3
import os
from flask import url_for
from ..util import live_server_setup, wait_for_all_checks
def do_test(client, live_server, make_test_use_extra_browser=False):
# Grep for this string in the logs?
test_url = "https://changedetection.io/ci-test.html?non-custom-default=true"
# "non... | 86 | 3,516 |
changedetection.io | changedetectionio/tests/llm/test_evaluator.py | .py | """
Unit tests for changedetectionio/llm/evaluator.py
Uses mocked LLM calls — no real API key needed.
"""
import pytest
from unittest.mock import patch, MagicMock
def _make_datastore(llm_cfg=None, tags=None):
"""Build a minimal datastore-like dict for testing."""
ds = MagicMock()
app_settings = {
... | 559 | 26,000 |
changedetection.io | changedetectionio/tests/llm/test_notification_tokens.py | .py | """
Tests that {{ llm_summary }} and {{ llm_intent }} notification tokens
are correctly populated in the notification pipeline.
Covers:
1. notification/handler.py — lazy population logic (lines 367-372)
2. notification_service.py — _llm_result / _llm_intent from watch → n_object
3. End-to-end: tokens render in n... | 326 | 12,843 |
changedetection.io | changedetectionio/tests/llm/test_llm_features_disabled.py | .py | """
Smoke test for the LLM_FEATURES_DISABLED env var.
The env var is intended to hide every LLM/AI surface (settings tab, edit tab,
base-template AI toggle/modal) for hosted deployments. This test renders the
three primary pages with the env var set and verifies that none of the
LLM-related markers leak through.
"""
f... | 63 | 2,861 |
changedetection.io | changedetectionio/tests/llm/test_llm_restock_plugin.py | .py | """
Tests for the LLM restock fallback plugin.
All LLM calls are mocked — no real API key required.
"""
import json
import pytest
from unittest.mock import patch, MagicMock
@pytest.fixture(autouse=True)
def _clear_llm_result_cache():
"""The plugin keeps a module-level result cache (keyed by model+prompt) so it w... | 328 | 13,073 |
changedetection.io | changedetectionio/tests/llm/test_prompt_builder.py | .py | """
Unit tests for changedetectionio/llm/prompt_builder.py
All functions are pure — no external dependencies needed.
"""
import pytest
from changedetectionio.llm.prompt_builder import (
build_eval_prompt,
build_eval_system_prompt,
build_setup_prompt,
build_setup_system_prompt,
SNAPSHOT_CONTEXT_CHAR... | 138 | 4,652 |
changedetection.io | changedetectionio/tests/llm/test_response_parser.py | .py | """
Unit tests for changedetectionio/llm/response_parser.py
All functions are pure — no external dependencies needed.
"""
import pytest
from changedetectionio.llm.response_parser import (
_extract_json,
parse_eval_response,
parse_setup_response,
)
class TestExtractJson:
def test_plain_json_passes_thr... | 147 | 5,925 |
changedetection.io | changedetectionio/tests/smtp/test_notification_smtp.py | .py | import time
from flask import url_for
from email import message_from_string
from email.policy import default as email_policy
from changedetectionio.diff import HTML_REMOVED_STYLE, HTML_ADDED_STYLE, HTML_CHANGED_STYLE, REMOVED_PLACEMARKER_OPEN, \
CHANGED_PLACEMARKER_OPEN, ADDED_PLACEMARKER_OPEN
from changedetection... | 780 | 32,105 |
changedetection.io | changedetectionio/tests/smtp/smtp-test-server.py | .py | #!/usr/bin/env python3
import threading
import time
from aiosmtpd.controller import Controller
from flask import Flask, Response
from email import message_from_bytes
from email.policy import default
# Accept a SMTP message and offer a way to retrieve the last message via HTTP
last_received_message = b"SMTP Test Serve... | 111 | 3,842 |
changedetection.io | changedetectionio/tests/apprise/test_apprise_custom_api_call.py | .py | import json
from unittest.mock import patch
import pytest
import requests
from apprise.utils.parse import parse_url as apprise_parse_url
from changedetectionio.notification.apprise_plugin.custom_handlers import (
_get_auth,
_get_headers,
_get_params,
apprise_http_custom_handler,
SUPPORTED_HTTP_MET... | 212 | 6,321 |
changedetection.io | changedetectionio/tests/apprise/test_apprise_asset.py | .py | import pytest
from apprise import AppriseAsset
from changedetectionio.notification.apprise_plugin.assets import (
APPRISE_APP_DESC,
APPRISE_APP_ID,
APPRISE_APP_URL,
APPRISE_AVATAR_URL,
)
@pytest.fixture(scope="function")
def apprise_asset() -> AppriseAsset:
from changedetectionio.notification.app... | 25 | 715 |
changedetection.io | changedetectionio/tests/visualselector/test_fetch_data.py | .py | #!/usr/bin/env python3
import os
from flask import url_for
from ..util import live_server_setup, wait_for_all_checks
# def test_setup(client, live_server, measure_memory_usage, datastore_path):
# live_server_setup(live_server) # Setup on conftest per function
# Add a site in paused mode, add an invalid filter, ... | 320 | 12,991 |
changedetection.io | changedetectionio/tests/proxy_list/test_multiple_proxy.py | .py | #!/usr/bin/env python3
import os
from flask import url_for
from ..util import live_server_setup, wait_for_all_checks
def test_preferred_proxy(client, live_server, measure_memory_usage, datastore_path):
# live_server_setup(live_server) # Setup on conftest per function
url = "http://chosen.changedetection.io"
... | 37 | 1,251 |
changedetection.io | changedetectionio/tests/proxy_list/test_proxy.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client
# 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_... | 20 | 768 |
changedetection.io | changedetectionio/tests/proxy_list/test_select_custom_proxy.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from ..util import live_server_setup, wait_for_all_checks
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, datastore_path):
# live_server_set... | 87 | 3,132 |
changedetection.io | changedetectionio/tests/proxy_list/test_proxy_noconnect.py | .py | #!/usr/bin/env python3
from flask import url_for
from ..util import live_server_setup, wait_for_all_checks
import os
from ... import strtobool
# Just to be sure the UI outputs the right error message on proxy connection failed
# docker run -p 4444:4444 --rm --shm-size="2g" selenium/standalone-chrome:4
# PLAYWRIGHT_... | 70 | 2,728 |
changedetection.io | changedetectionio/tests/proxy_list/test_noproxy.py | .py | #!/usr/bin/env python3
import time
from flask import url_for
from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client
def test_noproxy_option(client, live_server, measure_memory_usage, datastore_path):
# live_server_setup(live_server) # Setup on conftest per function
# Run by run_p... | 79 | 2,992 |
changedetection.io | changedetectionio/tests/unit/test_llm_restock_content.py | .py | #!/usr/bin/env python3
"""
Unit tests for the LLM restock fallback's prompt-content building (no LLM call needed):
* _extract_jsonld() keeps only JSON-LD blocks carrying price/stock info, dropping noise
(breadcrumbs, site metadata) that otherwise crowds out the useful data.
* _strip_html() sends the page's vis... | 71 | 3,023 |
changedetection.io | changedetectionio/tests/unit/test_time_handler.py | .py | #!/usr/bin/env python3
"""
Comprehensive tests for time_handler module refactored to use arrow.
Run from project root:
python3 -m pytest changedetectionio/tests/unit/test_time_handler.py -v
"""
import unittest
import unittest.mock
import arrow
from changedetectionio import time_handler
class TestAmIInsideTime(unit... | 805 | 30,790 |
changedetection.io | changedetectionio/tests/unit/test_extract_title.py | .py | #!/usr/bin/env python3
# coding=utf-8
"""Unit tests for html_tools.extract_title — including regression for #4217.
Issue #4217: extract_title silently returns None for pages where <title> is
pushed past the hard-coded 8 192-character scan window by large <head> content
(e.g. Amazon product pages where <title> can sit... | 136 | 5,902 |
changedetection.io | changedetectionio/tests/unit/test_xml_security.py | .py | #!/usr/bin/env python3
# run from dir above changedetectionio/ dir
# python3 -m pytest changedetectionio/tests/unit/test_xml_security.py
import pytest
from changedetectionio import html_tools
def _xxe_payload(file_path: str) -> str:
return f"""<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY xxe SYSTEM "file:/... | 36 | 1,168 |
changedetection.io | changedetectionio/tests/unit/test_conditions.py | .py | from changedetectionio.conditions import execute_ruleset_against_all_plugins
from changedetectionio.model import CONDITIONS_MATCH_LOGIC_DEFAULT
from changedetectionio.store import ChangeDetectionStore
import shutil
import tempfile
import time
import unittest
import uuid
class TestTriggerConditions(unittest.TestCase):... | 84 | 3,300 |
changedetection.io | changedetectionio/tests/unit/test_scheduler.py | .py | #!/usr/bin/env python3
# run from dir above changedetectionio/ dir
# python3 -m unittest changedetectionio.tests.unit.test_scheduler
import unittest
import arrow
class TestScheduler(unittest.TestCase):
# UTC+14:00 (Line Islands, Kiribati) is the farthest ahead, always ahead of UTC.
# UTC-12:00 (Baker Island... | 107 | 4,647 |
changedetection.io | changedetectionio/tests/unit/test_step_failure_notification.py | .py | """
Unit test for send_step_failure_notification regression.
Before the fix, line 499 called self._check_cascading_vars('notification_format', watch)
which raises AttributeError because _check_cascading_vars is a module-level function,
not a method of NotificationService.
"""
import queue
from unittest.mock import Ma... | 93 | 4,078 |
changedetection.io | changedetectionio/tests/unit/test_restock_logic.py | .py | #!/usr/bin/env python3
# run from dir above changedetectionio/ dir
# python3 -m unittest changedetectionio.tests.unit.test_restock_logic
import unittest
import os
import changedetectionio.processors.restock_diff.processor as restock_diff
# mostly
class TestDiffBuilder(unittest.TestCase):
def test_logic(self):
... | 22 | 782 |
changedetection.io | changedetectionio/tests/unit/test_temporary_watch_seed.py | .py | #!/usr/bin/env python3
"""
Unit tests for promoting an Add-Watch live snapshot into a real watch.
The Add Watch UI fetches a screenshot + xpath element data once (the "/snapshot"
endpoint), parks it under datastore/temporary/{uuid} in final on-disk format, and
on submit renames that directory into place as the new wat... | 209 | 10,122 |
changedetection.io | changedetectionio/tests/unit/test_restock_deal_filter.py | .py | #!/usr/bin/env python3
"""
Regression: the watch-list "deal" filter must not crash when a watch's `restock` field is a
plain dict rather than a Restock object.
The built-in extruct path stores a Restock, but plugin fallbacks (notably the LLM restock
scraper) store a plain dict. watch_is_deal() then called dict.get_pri... | 63 | 2,451 |
changedetection.io | changedetectionio/tests/unit/test_validate_url.py | .py | #!/usr/bin/env python3
# run from dir above changedetectionio/ dir
# python3 -m unittest changedetectionio.tests.unit.test_validate_url
import unittest
from changedetectionio.validate_url import is_safe_valid_url, normalize_url_encoding
class TestValidateUrl(unittest.TestCase):
def test_fragment_with_pipe_cha... | 63 | 2,627 |
changedetection.io | changedetectionio/tests/unit/test_notification_iana_restricted.py | .py | """
Unit tests for SSRF protection in the Apprise custom HTTP notification handler.
The handler (notification/apprise_plugin/custom_handlers.py) must block requests
to private/IANA-reserved addresses unless ALLOW_IANA_RESTRICTED_ADDRESSES=true.
"""
import pytest
from unittest.mock import patch, MagicMock
def _make_... | 128 | 5,419 |
changedetection.io | changedetectionio/tests/unit/test_watch_model.py | .py | #!/usr/bin/env python3
# run from dir above changedetectionio/ dir
# python3 -m unittest changedetectionio.tests.unit.test_notification_diff
import unittest
import os
import pickle
from copy import deepcopy
from changedetectionio.model import Watch, Tag
# mostly
class TestDiffBuilder(unittest.TestCase):
def te... | 383 | 17,081 |
changedetection.io | changedetectionio/tests/unit/test_semver.py | .py | #!/usr/bin/env python3
# run from dir above changedetectionio/ dir
# python3 -m unittest changedetectionio.tests.unit.test_semver
import re
import unittest
# The SEMVER regex
SEMVER_REGEX = r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-... | 65 | 2,094 |
changedetection.io | changedetectionio/tests/unit/test_time_extension.py | .py | #!/usr/bin/env python3
"""
Simple unit tests for TimeExtension that mimic how safe_jinja.py uses it.
These tests demonstrate that the environment.default_timezone override works
exactly as intended in the actual application code.
"""
import arrow
from jinja2.sandbox import ImmutableSandboxedEnvironment
from changedete... | 139 | 5,457 |
changedetection.io | changedetectionio/tests/unit/test_content_type_detection.py | .py | #!/usr/bin/env python3
# coding=utf-8
# run from dir above changedetectionio/ dir
# python3 -m unittest changedetectionio.tests.unit.test_content_type_detection
"""Unit tests for guess_stream_type() content-type classification.
Regression cover for #4302: a normal HTML page served as 'text/html;charset=utf-8' was
cl... | 132 | 6,743 |
changedetection.io | changedetectionio/tests/unit/test_notification_diff.py | .py | #!/usr/bin/env python3
# run from dir above changedetectionio/ dir
# python3 -m unittest changedetectionio.tests.unit.test_notification_diff
import unittest
import os
from changedetectionio import diff
from changedetectionio.diff import (
REMOVED_PLACEMARKER_OPEN,
REMOVED_PLACEMARKER_CLOSED,
ADDED_PLACEM... | 523 | 24,151 |
changedetection.io | changedetectionio/tests/unit/test_llm_settings.py | .py | #!/usr/bin/env python3
# run from dir above changedetectionio/ dir
# python3 -m unittest changedetectionio.tests.unit.test_llm_settings
import unittest
from pydantic import ValidationError
from changedetectionio.model.LLMSettings import (
LLMSettings,
LLM_DEFAULT_BUDGET_ACTION,
LLM_DEFAULT_LOCAL_TOKEN_M... | 162 | 7,253 |
changedetection.io | changedetectionio/tests/unit/test_jinja2_security.py | .py | #!/usr/bin/env python3
# run from dir above changedetectionio/ dir
# python3 -m unittest changedetectionio.tests.unit.test_jinja2_security
import unittest
from changedetectionio import jinja2_custom as safe_jinja
# mostly
class TestJinja2SSTI(unittest.TestCase):
def test_exception(self):
import jinja2
... | 62 | 2,415 |
changedetection.io | changedetectionio/tests/unit/test_jq_security.py | .py | #!/usr/bin/env python3
# run from dir above changedetectionio/ dir
# python3 -m unittest changedetectionio.tests.unit.test_jq_security
import unittest
class TestJqExpressionSecurity(unittest.TestCase):
def test_blocked_builtins_raise(self):
"""Each dangerous builtin must be rejected by validate_jq_expr... | 95 | 3,205 |
changedetection.io | changedetectionio/tests/unit/test_html_to_text.py | .py | #!/usr/bin/env python3
# coding=utf-8
"""Unit tests for html_tools.html_to_text function."""
import hashlib
import threading
import unittest
from queue import Queue
from changedetectionio.html_tools import html_to_text
class TestHtmlToText(unittest.TestCase):
"""Test html_to_text function for correctness and t... | 628 | 24,935 |
changedetection.io | changedetectionio/tests/unit/test_auth_decorator_order.py | .py | """
Static analysis test: verify @login_optionally_required is always applied
AFTER (inner to) @blueprint.route(), not before it.
In Flask, @route() must be the outermost decorator because it registers
whatever function it receives. If @login_optionally_required is placed
above @route(), the raw unprotected function g... | 86 | 3,167 |
changedetection.io | changedetectionio/tests/unit/test_tag_url_match.py | .py | #!/usr/bin/env python3
# run from dir above changedetectionio/ dir
# python3 -m unittest changedetectionio.tests.unit.test_tag_url_match
import unittest
from changedetectionio.model.Tag import model as TagModel
def make_tag(pattern):
"""Minimal Tag instance for testing matches_url — skips datastore wiring."""
... | 69 | 2,704 |
changedetection.io | changedetectionio/tests/plugins/test_processor.py | .py | import time
from flask import url_for
from changedetectionio.tests.util import wait_for_all_checks
def test_check_plugin_processor(client, live_server, measure_memory_usage, datastore_path):
# requires os-int intelligence plugin installed (first basic one we test with)
res = client.get(url_for("add_watch_u... | 42 | 1,757 |
changedetection.io | changedetectionio/tests/plugins/test_html_head_extras.py | .py | """Test that plugins can inject HTML into base.html <head> via get_html_head_extras hookimpl."""
import pytest
from flask import url_for, Response
from changedetectionio.pluggy_interface import hookimpl, plugin_manager
_MY_JS = "console.log('my_module_content loaded');"
_MY_CSS = ".my-module-example { color: red; }"
... | 84 | 3,675 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.