kopia lustrzana https://github.com/dgtlmoon/changedetection.io
Notification - Support for standard API calls post:// posts:// get:// gets:// delete:// deletes:// put:// puts:// (#1194)
rodzic
c12db2b725
commit
265f622e75
|
@ -121,7 +121,7 @@ def test_element_removal_full(client, live_server):
|
|||
url_for("import_page"), data={"urls": test_url}, follow_redirects=True
|
||||
)
|
||||
assert b"1 Imported" in res.data
|
||||
|
||||
time.sleep(1)
|
||||
# Goto the edit page, add the filter data
|
||||
# Not sure why \r needs to be added - absent of the #changetext this is not necessary
|
||||
subtractive_selectors_data = "header\r\nfooter\r\nnav\r\n#changetext"
|
||||
|
|
|
@ -77,7 +77,8 @@ def test_DNS_errors(client, live_server):
|
|||
time.sleep(3)
|
||||
|
||||
res = client.get(url_for("index"))
|
||||
assert b'Name or service not known' in res.data
|
||||
found_name_resolution_error = b"Temporary failure in name resolution" in res.data or b"Name or service not known" in res.data
|
||||
assert found_name_resolution_error
|
||||
# Should always record that we tried
|
||||
assert bytes("just now".encode('utf-8')) in res.data
|
||||
|
||||
|
|
|
@ -101,9 +101,6 @@ def test_check_ignore_text_functionality(client, live_server):
|
|||
)
|
||||
assert b"1 Imported" in res.data
|
||||
|
||||
# Trigger a check
|
||||
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)
|
||||
|
||||
|
@ -199,9 +196,6 @@ def test_check_global_ignore_text_functionality(client, live_server):
|
|||
)
|
||||
assert b"1 Imported" in res.data
|
||||
|
||||
# Trigger a check
|
||||
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)
|
||||
|
||||
|
|
|
@ -237,6 +237,7 @@ def test_check_notification(client, live_server):
|
|||
)
|
||||
|
||||
def test_notification_validation(client, live_server):
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
# re #242 - when you edited an existing new entry, it would not correctly show the notification settings
|
||||
|
@ -266,43 +267,15 @@ def test_notification_validation(client, live_server):
|
|||
# )
|
||||
# assert b"Notification Body and Title is required when a Notification URL is used" in res.data
|
||||
|
||||
# Now adding a wrong token should give us an error
|
||||
# Disabled for now
|
||||
# res = client.post(
|
||||
# url_for("settings_page"),
|
||||
# data={"application-notification_title": "New ChangeDetection.io Notification - {{watch_url}}",
|
||||
# "application-notification_body": "Rubbish: {{rubbish}}\n",
|
||||
# "application-notification_format": "Text",
|
||||
# "application-notification_urls": "json://localhost/foobar",
|
||||
# "requests-time_between_check-minutes": 180,
|
||||
# "fetch_backend": "html_requests"
|
||||
# },
|
||||
# follow_redirects=True
|
||||
# )
|
||||
# assert bytes("Token 'rubbish' is not a valid token or is unknown".encode('utf-8')) in res.data
|
||||
|
||||
# And trying to define an invalid Jinja2 template should also throw an error
|
||||
res = client.post(
|
||||
url_for("settings_page"),
|
||||
data={"application-notification_title": "New ChangeDetection.io Notification - {{ watch_url }}",
|
||||
"application-notification_body": "Rubbish: {{ rubbish }\n",
|
||||
"application-notification_urls": "json://foobar.com",
|
||||
"application-minutes_between_check": 180,
|
||||
"application-fetch_backend": "html_requests"
|
||||
},
|
||||
follow_redirects=True
|
||||
)
|
||||
assert bytes("This is not a valid Jinja2 template".encode('utf-8')) in res.data
|
||||
|
||||
|
||||
# cleanup for the next
|
||||
client.get(
|
||||
url_for("form_delete", uuid="all"),
|
||||
follow_redirects=True
|
||||
)
|
||||
|
||||
def test_notification_jinja2(client, live_server):
|
||||
#live_server_setup(live_server)
|
||||
|
||||
|
||||
def test_notification_custom_endpoint_and_jinja2(client, live_server):
|
||||
time.sleep(1)
|
||||
|
||||
# test_endpoint - that sends the contents of a file
|
||||
|
@ -341,6 +314,7 @@ def test_notification_jinja2(client, live_server):
|
|||
client.get(url_for("form_watch_checknow"), follow_redirects=True)
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
with open("test-datastore/notification.txt", 'r') as f:
|
||||
x=f.read()
|
||||
j = json.loads(x)
|
||||
|
@ -352,4 +326,6 @@ def test_notification_jinja2(client, live_server):
|
|||
with open("test-datastore/notification-url.txt", 'r') as f:
|
||||
notification_url = f.read()
|
||||
assert 'xxx=http' in notification_url
|
||||
os.unlink("test-datastore/notification-url.txt")
|
||||
|
||||
os.unlink("test-datastore/notification-url.txt")
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue