Fetching when a trigger rule is found that does not match, should allow the last md5 to update, so that we know to recheck it

no-change-when-checksum-same
dgtlmoon 1 year ago
parent 3a9ed7f69e
commit 592e1b37c0

@ -306,8 +306,8 @@ class perform_site_check(difference_detection_processor):
if not rendered_diff and stripped_text_from_html: if not rendered_diff and stripped_text_from_html:
# We had some content, but no differences were found # We had some content, but no differences were found
# Store our new file as the MD5 so it will trigger in the future # Store our new file as the MD5 so it will trigger in the future
c = hashlib.md5(text_content_before_ignored_filter.translate(None, b'\r\n\t ')).hexdigest() update_obj['previous_md5'] = hashlib.md5(text_content_before_ignored_filter.translate(None, b'\r\n\t ')).hexdigest()
return False, {'previous_md5': c}, stripped_text_from_html.encode('utf-8') return False, update_obj, stripped_text_from_html.encode('utf-8')
else: else:
stripped_text_from_html = rendered_diff stripped_text_from_html = rendered_diff

@ -29,7 +29,6 @@ def set_original(excluding=None, add_line=None):
for i in test_return_data.splitlines(): for i in test_return_data.splitlines():
if not excluding in i: if not excluding in i:
output += f"{i}\n" output += f"{i}\n"
test_return_data = output test_return_data = output
with open("test-datastore/endpoint-content.txt", "w") as f: with open("test-datastore/endpoint-content.txt", "w") as f:
@ -39,9 +38,8 @@ def test_setup(client, live_server):
live_server_setup(live_server) live_server_setup(live_server)
def test_check_removed_line_contains_trigger(client, live_server): def test_check_removed_line_contains_trigger(client, live_server):
#live_server_setup(live_server)
# Give the endpoint time to spin up # Give the endpoint time to spin up
time.sleep(1)
set_original() set_original()
# Add our URL to the import page # Add our URL to the import page
test_url = url_for('test_endpoint', _external=True) test_url = url_for('test_endpoint', _external=True)
@ -52,9 +50,14 @@ def test_check_removed_line_contains_trigger(client, live_server):
) )
assert b"1 Imported" in res.data assert b"1 Imported" in res.data
from .util import extract_UUID_from_client
uuid = extract_UUID_from_client(client)
# Give the thread time to pick it up # Give the thread time to pick it up
wait_for_all_checks(client) wait_for_all_checks(client)
#assert live_server.app.config['DATASTORE'].data['watching'][uuid]['previous_md5_before_filters'] == '3f10f9d7e3bc2b04197f525b30ca05af'
# Goto the edit page, add our ignore text # Goto the edit page, add our ignore text
# Add our URL to the import page # Add our URL to the import page
res = client.post( res = client.post(
@ -67,12 +70,13 @@ def test_check_removed_line_contains_trigger(client, live_server):
) )
assert b"Updated watch." in res.data assert b"Updated watch." in res.data
wait_for_all_checks(client) wait_for_all_checks(client)
set_original(excluding='Something irrelevant')
set_original(excluding='Something irrelevant')
# A line thats not the trigger should not trigger anything # A line thats not the trigger should not trigger anything
res = client.get(url_for("form_watch_checknow"), follow_redirects=True) res = client.get(url_for("form_watch_checknow"), follow_redirects=True)
assert b'1 watches queued for rechecking.' in res.data assert b'1 watches queued for rechecking.' in res.data
wait_for_all_checks(client) wait_for_all_checks(client)
assert live_server.app.config['DATASTORE'].data['watching'][uuid]['previous_md5_before_filters'] == '1262fa651e226e126fabe0275e131e82'
res = client.get(url_for("index")) res = client.get(url_for("index"))
assert b'unviewed' not in res.data assert b'unviewed' not in res.data
@ -92,10 +96,14 @@ def test_check_removed_line_contains_trigger(client, live_server):
res = client.get(url_for("index")) res = client.get(url_for("index"))
assert b'unviewed' not in res.data assert b'unviewed' not in res.data
# Remove it again, and we should get a trigger # It should now have 'The golden line' back, so we remove it, check again
# We should get a trigger
set_original(excluding='The golden line') set_original(excluding='The golden line')
client.get(url_for("form_watch_checknow"), follow_redirects=True) client.get(url_for("form_watch_checknow"), follow_redirects=True)
wait_for_all_checks(client) wait_for_all_checks(client)
#assert live_server.app.config['DATASTORE'].data['watching'][uuid]['previous_md5_before_filters'] == '2288c23519a6a90809defb37d79f98f4'
res = client.get(url_for("preview_page", uuid="first"))
assert b'The golden line' not in res.data
res = client.get(url_for("index")) res = client.get(url_for("index"))
assert b'unviewed' in res.data assert b'unviewed' in res.data
@ -107,7 +115,7 @@ def test_check_add_line_contains_trigger(client, live_server):
#live_server_setup(live_server) #live_server_setup(live_server)
# Give the endpoint time to spin up # Give the endpoint time to spin up
time.sleep(1) #time.sleep(1)
test_notification_url = url_for('test_notification_endpoint', _external=True).replace('http://', 'post://') + "?xxx={{ watch_url }}" test_notification_url = url_for('test_notification_endpoint', _external=True).replace('http://', 'post://') + "?xxx={{ watch_url }}"
res = client.post( res = client.post(

@ -427,7 +427,6 @@ class update_worker(threading.Thread):
if update_handler.xpath_data: if update_handler.xpath_data:
self.datastore.save_xpath_data(watch_uuid=uuid, data=update_handler.xpath_data) self.datastore.save_xpath_data(watch_uuid=uuid, data=update_handler.xpath_data)
self.current_uuid = None # Done self.current_uuid = None # Done
self.q.task_done() self.q.task_done()

Loading…
Cancel
Save