|
|
|
@ -151,3 +151,88 @@ def test_check_ignore_text_functionality(client, live_server):
|
|
|
|
|
|
|
|
|
|
res = client.get(url_for("api_delete", uuid="all"), follow_redirects=True)
|
|
|
|
|
assert b'Deleted' in res.data
|
|
|
|
|
|
|
|
|
|
def test_check_global_ignore_text_functionality(client, live_server):
|
|
|
|
|
sleep_time_for_fetch_thread = 3
|
|
|
|
|
|
|
|
|
|
ignore_text = "XXXXX\r\nYYYYY\r\nZZZZZ"
|
|
|
|
|
set_original_ignore_response()
|
|
|
|
|
|
|
|
|
|
# Give the endpoint time to spin up
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
# Add our URL to the import page
|
|
|
|
|
test_url = url_for('test_endpoint', _external=True)
|
|
|
|
|
res = client.post(
|
|
|
|
|
url_for("import_page"),
|
|
|
|
|
data={"urls": test_url},
|
|
|
|
|
follow_redirects=True
|
|
|
|
|
)
|
|
|
|
|
assert b"1 Imported" in res.data
|
|
|
|
|
|
|
|
|
|
# Trigger a check
|
|
|
|
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
|
|
|
|
|
|
|
|
|
# Give the thread time to pick it up
|
|
|
|
|
time.sleep(sleep_time_for_fetch_thread)
|
|
|
|
|
|
|
|
|
|
# Goto the settings page, add our ignore text
|
|
|
|
|
res = client.post(
|
|
|
|
|
url_for("settings_page"),
|
|
|
|
|
data={
|
|
|
|
|
"minutes_between_check": 180,
|
|
|
|
|
"global_ignore_text": ignore_text,
|
|
|
|
|
'fetch_backend': "html_requests"
|
|
|
|
|
},
|
|
|
|
|
follow_redirects=True
|
|
|
|
|
)
|
|
|
|
|
assert b"Settings updated." in res.data
|
|
|
|
|
|
|
|
|
|
# Goto the edit page of the item, add our ignore text
|
|
|
|
|
# Add our URL to the import page
|
|
|
|
|
res = client.post(
|
|
|
|
|
url_for("edit_page", uuid="first"),
|
|
|
|
|
data={"ignore_text": "something irrelevent but just to check", "url": test_url, 'fetch_backend': "html_requests"},
|
|
|
|
|
follow_redirects=True
|
|
|
|
|
)
|
|
|
|
|
assert b"Updated watch." in res.data
|
|
|
|
|
|
|
|
|
|
# Check it saved
|
|
|
|
|
res = client.get(
|
|
|
|
|
url_for("settings_page"),
|
|
|
|
|
)
|
|
|
|
|
assert bytes(ignore_text.encode('utf-8')) in res.data
|
|
|
|
|
|
|
|
|
|
# Trigger a check
|
|
|
|
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
|
|
|
|
|
|
|
|
|
# Give the thread time to pick it up
|
|
|
|
|
time.sleep(sleep_time_for_fetch_thread)
|
|
|
|
|
|
|
|
|
|
# It should report nothing found (no new 'unviewed' class)
|
|
|
|
|
res = client.get(url_for("index"))
|
|
|
|
|
assert b'unviewed' not in res.data
|
|
|
|
|
assert b'/test-endpoint' in res.data
|
|
|
|
|
|
|
|
|
|
# Make a change
|
|
|
|
|
set_modified_ignore_response()
|
|
|
|
|
|
|
|
|
|
# Trigger a check
|
|
|
|
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
|
|
|
|
# Give the thread time to pick it up
|
|
|
|
|
time.sleep(sleep_time_for_fetch_thread)
|
|
|
|
|
|
|
|
|
|
# It should report nothing found (no new 'unviewed' class)
|
|
|
|
|
res = client.get(url_for("index"))
|
|
|
|
|
assert b'unviewed' not in res.data
|
|
|
|
|
assert b'/test-endpoint' in res.data
|
|
|
|
|
|
|
|
|
|
# Just to be sure.. set a regular modified change..
|
|
|
|
|
set_modified_original_ignore_response()
|
|
|
|
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
|
|
|
|
time.sleep(sleep_time_for_fetch_thread)
|
|
|
|
|
res = client.get(url_for("index"))
|
|
|
|
|
assert b'unviewed' in res.data
|
|
|
|
|
|
|
|
|
|
res = client.get(url_for("api_delete", uuid="all"), follow_redirects=True)
|
|
|
|
|
assert b'Deleted' in res.data
|