From d7bc2bd3f69eab37fadaeb4bb46fb551f7ce579d Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 7 Nov 2023 14:42:34 +0100 Subject: [PATCH] cleanups --- changedetectionio/processors/__init__.py | 3 ++- changedetectionio/tests/test_extract_csv.py | 2 +- changedetectionio/tests/test_request.py | 6 +++++- changedetectionio/update_worker.py | 3 +++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/changedetectionio/processors/__init__.py b/changedetectionio/processors/__init__.py index 1cee9ae3..92ba46a8 100644 --- a/changedetectionio/processors/__init__.py +++ b/changedetectionio/processors/__init__.py @@ -1,6 +1,7 @@ from abc import abstractmethod import os import hashlib +from copy import deepcopy from changedetectionio import content_fetcher @@ -15,7 +16,7 @@ class difference_detection_processor(): def __init__(self, *args, datastore, watch_uuid, **kwargs): super().__init__(*args, **kwargs) self.datastore = datastore - self.watch = self.datastore.data['watching'].get(watch_uuid) + self.watch = deepcopy(self.datastore.data['watching'].get(watch_uuid)) def call_browser(self): diff --git a/changedetectionio/tests/test_extract_csv.py b/changedetectionio/tests/test_extract_csv.py index 220b12aa..52596a9e 100644 --- a/changedetectionio/tests/test_extract_csv.py +++ b/changedetectionio/tests/test_extract_csv.py @@ -24,7 +24,7 @@ def test_check_extract_text_from_diff(client, live_server): ) assert b"1 Imported" in res.data - time.sleep(1) + wait_for_all_checks(client) # Load in 5 different numbers/changes last_date="" diff --git a/changedetectionio/tests/test_request.py b/changedetectionio/tests/test_request.py index 55c2e342..9586363f 100644 --- a/changedetectionio/tests/test_request.py +++ b/changedetectionio/tests/test_request.py @@ -80,8 +80,11 @@ def test_headers_in_request(client, live_server): # Should be only one with headers set assert watches_with_headers==1 + res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) + assert b'Deleted' in res.data def test_body_in_request(client, live_server): + # Add our URL to the import page test_url = url_for('test_body', _external=True) if os.getenv('PLAYWRIGHT_DRIVER_URL'): @@ -170,7 +173,8 @@ def test_body_in_request(client, live_server): follow_redirects=True ) assert b"Body must be empty when Request Method is set to GET" in res.data - + res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) + assert b'Deleted' in res.data def test_method_in_request(client, live_server): # Add our URL to the import page diff --git a/changedetectionio/update_worker.py b/changedetectionio/update_worker.py index d1045230..c5ab7de9 100644 --- a/changedetectionio/update_worker.py +++ b/changedetectionio/update_worker.py @@ -410,6 +410,9 @@ class update_worker(threading.Thread): self.datastore.update_watch(uuid=uuid, update_obj={'last_error': str(e)}) # Other serious error process_changedetection_results = False +# import traceback +# print(traceback.format_exc()) + else: # Crash protection, the watch entry could have been removed by this point (during a slow chrome fetch etc) if not self.datastore.data['watching'].get(uuid):