mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-12-08 09:05:36 +00:00
This commit is contained in:
@@ -503,7 +503,9 @@ class ValidateJinja2Template(object):
|
|||||||
jinja2_env = create_jinja_env(loader=BaseLoader)
|
jinja2_env = create_jinja_env(loader=BaseLoader)
|
||||||
|
|
||||||
# Add notification tokens for validation
|
# Add notification tokens for validation
|
||||||
jinja2_env.globals.update(NotificationContextData())
|
static_token_placeholders = NotificationContextData()
|
||||||
|
static_token_placeholders.set_random_for_validation()
|
||||||
|
jinja2_env.globals.update(static_token_placeholders)
|
||||||
if hasattr(field, 'extra_notification_tokens'):
|
if hasattr(field, 'extra_notification_tokens'):
|
||||||
jinja2_env.globals.update(field.extra_notification_tokens)
|
jinja2_env.globals.update(field.extra_notification_tokens)
|
||||||
|
|
||||||
|
|||||||
@@ -302,15 +302,20 @@ def test_notification_urls_jinja2_apprise_integration(client, live_server, measu
|
|||||||
data={
|
data={
|
||||||
"application-fetch_backend": "html_requests",
|
"application-fetch_backend": "html_requests",
|
||||||
"application-minutes_between_check": 180,
|
"application-minutes_between_check": 180,
|
||||||
"application-notification_body": '{ "url" : "{{ watch_url }}", "secret": 444, "somebug": "网站监测 内容更新了" }',
|
"application-notification_body": '{ "url" : "{{ watch_url }}", "secret": 444, "somebug": "网站监测 内容更新了", "another": "{{diff|truncate(1500)}}" }',
|
||||||
"application-notification_format": default_notification_format,
|
"application-notification_format": default_notification_format,
|
||||||
"application-notification_urls": test_notification_url,
|
"application-notification_urls": test_notification_url,
|
||||||
# https://github.com/caronc/apprise/wiki/Notify_Custom_JSON#get-parameter-manipulation
|
# https://github.com/caronc/apprise/wiki/Notify_Custom_JSON#get-parameter-manipulation
|
||||||
"application-notification_title": "New ChangeDetection.io Notification - {{ watch_url }} ",
|
"application-notification_title": "New ChangeDetection.io Notification - {{ watch_url }} {{diff|truncate(200)}} ",
|
||||||
},
|
},
|
||||||
follow_redirects=True
|
follow_redirects=True
|
||||||
)
|
)
|
||||||
assert b'Settings updated' in res.data
|
assert b'Settings updated' in res.data
|
||||||
|
assert '网站监测'.encode() in res.data
|
||||||
|
assert b'{{diff|truncate(1500)}}' in res.data
|
||||||
|
assert b'{{diff|truncate(200)}}' in res.data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_notification_custom_endpoint_and_jinja2(client, live_server, measure_memory_usage, datastore_path):
|
def test_notification_custom_endpoint_and_jinja2(client, live_server, measure_memory_usage, datastore_path):
|
||||||
|
|||||||
Reference in New Issue
Block a user