Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion changedetectionio/content_fetchers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def run(self,
pass

@abstractmethod
def quit(self):
def quit(self, watch=None):
return

@abstractmethod
Expand Down
14 changes: 14 additions & 0 deletions changedetectionio/content_fetchers/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,17 @@ def run(self,


self.raw_content = r.content

def quit(self, watch=None):

# In case they switched to `requests` fetcher from something else
# Then the screenshot could be old, in any case, it's not used here.
# REMOVE_REQUESTS_OLD_SCREENSHOTS - Mainly used for testing
if strtobool(os.getenv("REMOVE_REQUESTS_OLD_SCREENSHOTS", 'true')):
screenshot = watch.get_screenshot()
if screenshot:
try:
os.unlink(screenshot)
except Exception as e:
logger.warning(f"Failed to unlink screenshot: {screenshot} - {e}")

2 changes: 1 addition & 1 deletion changedetectionio/content_fetchers/webdriver_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def is_ready(self):
self.quit()
return True

def quit(self):
def quit(self, watch=None):
if self.driver:
try:
self.driver.quit()
Expand Down
2 changes: 1 addition & 1 deletion changedetectionio/processors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def call_browser(self, preferred_proxy_id=None):
)

#@todo .quit here could go on close object, so we can run JS if change-detected
self.fetcher.quit()
self.fetcher.quit(watch=self.watch)

# After init, call run_changedetection() which will do the actual change-detection

Expand Down
7 changes: 4 additions & 3 deletions changedetectionio/run_basic_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
find tests/test_*py -type f|while read test_name
do
echo "TEST RUNNING $test_name"
pytest $test_name
# REMOVE_REQUESTS_OLD_SCREENSHOTS disabled so that we can write a screenshot and send it in test_notifications.py without a real browser
REMOVE_REQUESTS_OLD_SCREENSHOTS=false pytest $test_name
done

echo "RUNNING WITH BASE_URL SET"

# Now re-run some tests with BASE_URL enabled
# Re #65 - Ability to include a link back to the installation, in the notification.
export BASE_URL="https://really-unique-domain.io"
pytest tests/test_notification.py
REMOVE_REQUESTS_OLD_SCREENSHOTS=false pytest tests/test_notification.py


# Re-run with HIDE_REFERER set - could affect login
Expand All @@ -32,7 +33,7 @@ pytest tests/test_access_control.py
# Re-run a few tests that will trigger brotli based storage
export SNAPSHOT_BROTLI_COMPRESSION_THRESHOLD=5
pytest tests/test_access_control.py
pytest tests/test_notification.py
REMOVE_REQUESTS_OLD_SCREENSHOTS=false pytest tests/test_notification.py
pytest tests/test_backend.py
pytest tests/test_rss.py
pytest tests/test_unique_lines.py
Expand Down