|
|
@ -1,12 +1,7 @@
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
from flask import url_for
|
|
|
|
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
|
|
|
|
from .util import set_original_response, set_modified_response, live_server_setup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sleep_time_for_fetch_thread = 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_nonrenderable_response():
|
|
|
|
def set_nonrenderable_response():
|
|
|
|
test_return_data = """<html>
|
|
|
|
test_return_data = """<html>
|
|
|
@ -22,6 +17,13 @@ def set_nonrenderable_response():
|
|
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_zero_byte_response():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open("test-datastore/endpoint-content.txt", "w") as f:
|
|
|
|
|
|
|
|
f.write("")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def test_check_basic_change_detection_functionality(client, live_server, measure_memory_usage):
|
|
|
|
def test_check_basic_change_detection_functionality(client, live_server, measure_memory_usage):
|
|
|
|
set_original_response()
|
|
|
|
set_original_response()
|
|
|
|
live_server_setup(live_server)
|
|
|
|
live_server_setup(live_server)
|
|
|
@ -35,14 +37,7 @@ def test_check_basic_change_detection_functionality(client, live_server, measure
|
|
|
|
|
|
|
|
|
|
|
|
assert b"1 Imported" in res.data
|
|
|
|
assert b"1 Imported" in res.data
|
|
|
|
|
|
|
|
|
|
|
|
time.sleep(sleep_time_for_fetch_thread)
|
|
|
|
wait_for_all_checks(client)
|
|
|
|
|
|
|
|
|
|
|
|
# Do this a few times.. ensures we dont accidently set the status
|
|
|
|
|
|
|
|
for n in range(3):
|
|
|
|
|
|
|
|
client.get(url_for("form_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)
|
|
|
|
# It should report nothing found (no new 'unviewed' class)
|
|
|
|
res = client.get(url_for("index"))
|
|
|
|
res = client.get(url_for("index"))
|
|
|
@ -64,7 +59,7 @@ def test_check_basic_change_detection_functionality(client, live_server, measure
|
|
|
|
client.get(url_for("form_watch_checknow"), follow_redirects=True)
|
|
|
|
client.get(url_for("form_watch_checknow"), follow_redirects=True)
|
|
|
|
|
|
|
|
|
|
|
|
# Give the thread time to pick it up
|
|
|
|
# Give the thread time to pick it up
|
|
|
|
time.sleep(sleep_time_for_fetch_thread)
|
|
|
|
wait_for_all_checks(client)
|
|
|
|
|
|
|
|
|
|
|
|
# It should report nothing found (no new 'unviewed' class)
|
|
|
|
# It should report nothing found (no new 'unviewed' class)
|
|
|
|
res = client.get(url_for("index"))
|
|
|
|
res = client.get(url_for("index"))
|
|
|
@ -86,14 +81,20 @@ def test_check_basic_change_detection_functionality(client, live_server, measure
|
|
|
|
client.get(url_for("form_watch_checknow"), follow_redirects=True)
|
|
|
|
client.get(url_for("form_watch_checknow"), follow_redirects=True)
|
|
|
|
|
|
|
|
|
|
|
|
# Give the thread time to pick it up
|
|
|
|
# Give the thread time to pick it up
|
|
|
|
time.sleep(sleep_time_for_fetch_thread)
|
|
|
|
wait_for_all_checks(client)
|
|
|
|
|
|
|
|
|
|
|
|
# It should report nothing found (no new 'unviewed' class)
|
|
|
|
# It should report nothing found (no new 'unviewed' class)
|
|
|
|
res = client.get(url_for("index"))
|
|
|
|
res = client.get(url_for("index"))
|
|
|
|
assert b'unviewed' in res.data
|
|
|
|
assert b'unviewed' in res.data
|
|
|
|
|
|
|
|
client.get(url_for("mark_all_viewed"), follow_redirects=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# A totally zero byte (#2528) response should also not trigger an error
|
|
|
|
|
|
|
|
set_zero_byte_response()
|
|
|
|
|
|
|
|
client.get(url_for("form_watch_checknow"), follow_redirects=True)
|
|
|
|
|
|
|
|
wait_for_all_checks(client)
|
|
|
|
|
|
|
|
res = client.get(url_for("index"))
|
|
|
|
|
|
|
|
assert b'unviewed' in res.data # A change should have registered because empty_pages_are_a_change is ON
|
|
|
|
|
|
|
|
assert b'fetch-error' not in res.data
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Cleanup everything
|
|
|
|
# Cleanup everything
|
|
|
|