mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-12-18 14:05:34 +00:00
* issue #4 Adding settings screen for apprise URLS * Adding test notification mechanism * Move Worker module to own class file * Adding basic notification URL runner * Tests for notifications * Tweak readme with notification info * Move notification test to main test_backend.py * Fix spacing * Adding notifications screenshot * Cleanup more files from test * Offer send notification test on individual edits and main/default * Process global notifications * All branches test * Wrap worker notification process in try/catch, use global if nothing set * Fix syntax * Handle exception, increase wait time for liveserver to come up * Fixing test setup * remove debug * Split tests into their own totally isolated setups, if you know a better way to make live_server() work, MR :) * Tidying up lint/imports
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
#!/usr/bin/python3
|
|
|
|
|
|
def set_original_response():
|
|
test_return_data = """<html>
|
|
<body>
|
|
Some initial text</br>
|
|
<p>Which is across multiple lines</p>
|
|
</br>
|
|
So let's see what happens. </br>
|
|
</body>
|
|
</html>
|
|
"""
|
|
|
|
with open("test-datastore/output.txt", "w") as f:
|
|
f.write(test_return_data)
|
|
return None
|
|
|
|
def set_modified_response():
|
|
test_return_data = """<html>
|
|
<body>
|
|
Some initial text</br>
|
|
<p>which has this one new line</p>
|
|
</br>
|
|
So let's see what happens. </br>
|
|
</body>
|
|
</html>
|
|
"""
|
|
|
|
with open("test-datastore/output.txt", "w") as f:
|
|
f.write(test_return_data)
|
|
|
|
return None
|
|
|
|
|
|
def live_server_setup(live_server):
|
|
|
|
@live_server.app.route('/test-endpoint')
|
|
def test_endpoint():
|
|
# Tried using a global var here but didn't seem to work, so reading from a file instead.
|
|
with open("test-datastore/output.txt", "r") as f:
|
|
return f.read()
|
|
|
|
@live_server.app.route('/test_notification_endpoint', methods=['POST'])
|
|
def test_notification_endpoint():
|
|
with open("test-datastore/count.txt", "w") as f:
|
|
f.write("we hit it")
|
|
print("\n>> Test notification endpoint was hit.\n")
|
|
return "Text was set"
|
|
|
|
# And this should return not zero.
|
|
@live_server.app.route('/test_notification_counter')
|
|
def test_notification_counter():
|
|
try:
|
|
with open("test-datastore/count.txt", "r") as f:
|
|
return f.read()
|
|
except FileNotFoundError:
|
|
return "nope :("
|
|
|
|
live_server.start() |