2024-07-25 12:39:01 +00:00
|
|
|
#!/usr/bin/env python3
|
2023-08-24 12:29:48 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
def set_original_ignore_response():
|
|
|
|
test_return_data = """<html>
|
|
|
|
<body>
|
|
|
|
Some initial text<br>
|
|
|
|
<p>Which is across multiple lines</p>
|
|
|
|
<br>
|
|
|
|
So let's see what happens. <br>
|
|
|
|
<p>oh yeah 456</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
with open("test-datastore/endpoint-content.txt", "w") as f:
|
|
|
|
f.write(test_return_data)
|
|
|
|
|
|
|
|
|
2024-10-05 14:32:28 +00:00
|
|
|
def test_ignore(client, live_server, measure_memory_usage):
|
2023-08-24 12:29:48 +00:00
|
|
|
live_server_setup(live_server)
|
|
|
|
set_original_ignore_response()
|
|
|
|
test_url = url_for('test_endpoint', _external=True)
|
|
|
|
res = client.post(
|
2025-03-18 09:40:22 +00:00
|
|
|
url_for("imports.import_page"),
|
2023-08-24 12:29:48 +00:00
|
|
|
data={"urls": test_url},
|
|
|
|
follow_redirects=True
|
|
|
|
)
|
|
|
|
assert b"1 Imported" in res.data
|
|
|
|
|
|
|
|
# Give the thread time to pick it up
|
|
|
|
wait_for_all_checks(client)
|
2025-01-28 17:14:49 +00:00
|
|
|
uuid = next(iter(live_server.app.config['DATASTORE'].data['watching']))
|
2023-08-24 12:29:48 +00:00
|
|
|
# use the highlighter endpoint
|
|
|
|
res = client.post(
|
2025-03-18 09:40:22 +00:00
|
|
|
url_for("ui.ui_edit.highlight_submit_ignore_url", uuid=uuid),
|
2023-08-24 12:29:48 +00:00
|
|
|
data={"mode": 'digit-regex', 'selection': 'oh yeah 123'},
|
|
|
|
follow_redirects=True
|
|
|
|
)
|
|
|
|
|
2025-03-18 09:40:22 +00:00
|
|
|
res = client.get(url_for("ui.ui_edit.edit_page", uuid=uuid))
|
2023-08-24 12:29:48 +00:00
|
|
|
# should be a regex now
|
|
|
|
assert b'/oh\ yeah\ \d+/' in res.data
|
|
|
|
|
|
|
|
# Should return a link
|
|
|
|
assert b'href' in res.data
|
|
|
|
|
2024-10-05 14:32:28 +00:00
|
|
|
# It should not be in the preview anymore
|
2025-03-18 09:40:22 +00:00
|
|
|
res = client.get(url_for("ui.ui_views.preview_page", uuid=uuid))
|
2024-10-05 14:32:28 +00:00
|
|
|
assert b'<div class="ignored">oh yeah 456' not in res.data
|
2024-07-03 17:26:33 +00:00
|
|
|
|
|
|
|
# Should be in base.html
|
|
|
|
assert b'csrftoken' in res.data
|
|
|
|
|