mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-11-08 18:47:32 +00:00
Some checks failed
Build and push containers / metadata (push) Has been cancelled
Build and push containers / build-push-containers (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Has been cancelled
ChangeDetection.io App Test / lint-code (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Test the built 📦 package works basically. (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-10 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-11 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-12 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-13 (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
94 lines
2.7 KiB
Python
94 lines
2.7 KiB
Python
#!/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
|
|
|
|
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()
|
|
test_url = 'source:'+url_for('test_endpoint', _external=True)
|
|
# Add our URL to the import page
|
|
res = client.post(
|
|
url_for("imports.import_page"),
|
|
data={"urls": test_url},
|
|
follow_redirects=True
|
|
)
|
|
|
|
assert b"1 Imported" in res.data
|
|
|
|
time.sleep(sleep_time_for_fetch_thread)
|
|
|
|
#####################
|
|
|
|
# Check HTML conversion detected and workd
|
|
res = client.get(
|
|
url_for("ui.ui_views.preview_page", uuid="first"),
|
|
follow_redirects=True
|
|
)
|
|
|
|
# Check this class DOES appear (that we didnt see the actual source)
|
|
assert b'foobar-detection' in res.data
|
|
|
|
# Make a change
|
|
set_modified_response()
|
|
|
|
# Force recheck
|
|
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)
|
|
|
|
# Now something should be ready, indicated by having a 'unviewed' class
|
|
res = client.get(url_for("index"))
|
|
assert b'unviewed' in res.data
|
|
|
|
res = client.get(
|
|
url_for("ui.ui_views.diff_history_page", uuid="first"),
|
|
follow_redirects=True
|
|
)
|
|
|
|
assert b'<title>modified head title' in res.data
|
|
|
|
|
|
|
|
# `subtractive_selectors` should still work in `source:` type requests
|
|
def test_check_ignore_elements(client, live_server, measure_memory_usage):
|
|
set_original_response()
|
|
time.sleep(1)
|
|
test_url = 'source:'+url_for('test_endpoint', _external=True)
|
|
# Add our URL to the import page
|
|
res = client.post(
|
|
url_for("imports.import_page"),
|
|
data={"urls": test_url},
|
|
follow_redirects=True
|
|
)
|
|
|
|
assert b"1 Imported" in res.data
|
|
|
|
wait_for_all_checks(client)
|
|
|
|
#####################
|
|
# We want <span> and <p> ONLY, but ignore span with .foobar-detection
|
|
|
|
client.post(
|
|
url_for("ui.ui_edit.edit_page", uuid="first"),
|
|
data={"include_filters": 'span,p', "url": test_url, "tags": "", "subtractive_selectors": ".foobar-detection", 'fetch_backend': "html_requests"},
|
|
follow_redirects=True
|
|
)
|
|
|
|
time.sleep(sleep_time_for_fetch_thread)
|
|
|
|
res = client.get(
|
|
url_for("ui.ui_views.preview_page", uuid="first"),
|
|
follow_redirects=True
|
|
)
|
|
assert b'foobar-detection' not in res.data
|
|
assert b'<br' not in res.data
|
|
assert b'<p' in res.data
|