mirror of
https://github.com/getredash/redash.git
synced 2026-05-08 00:00:46 -04:00
Fixing failure report rendering (#5492)
This commit is contained in:
@@ -211,7 +211,7 @@ def render_template(path, context):
|
||||
Using Flask's `render_template` function requires the entire app context to load, which in turn triggers any
|
||||
function decorated with the `context_processor` decorator, which is not explicitly required for rendering purposes.
|
||||
"""
|
||||
current_app.jinja_env.get_template(path).render(**context)
|
||||
return current_app.jinja_env.get_template(path).render(**context)
|
||||
|
||||
|
||||
def query_is_select_no_limit(query):
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
from collections import namedtuple
|
||||
from unittest import TestCase
|
||||
|
||||
from redash import create_app
|
||||
from redash.utils import (
|
||||
build_url,
|
||||
collect_parameters_from_request,
|
||||
filter_none,
|
||||
json_dumps,
|
||||
generate_token,
|
||||
render_template,
|
||||
)
|
||||
|
||||
|
||||
@@ -78,3 +80,15 @@ class TestGenerateToken(TestCase):
|
||||
def test_format(self):
|
||||
token = generate_token(40)
|
||||
self.assertRegex(token, r"[a-zA-Z0-9]{40}")
|
||||
|
||||
class TestRenderTemplate(TestCase):
|
||||
def test_render(self):
|
||||
app = create_app()
|
||||
with app.app_context():
|
||||
d = {"failures": [{"id": 1, "name": "Failure Unit Test", "failed_at": "May 04, 2021 02:07PM UTC", "failure_reason": "", "failure_count": 1, "comment": None}]}
|
||||
html, text = [
|
||||
render_template("emails/failures.{}".format(f), d)
|
||||
for f in ["html", "txt"]
|
||||
]
|
||||
self.assertIn('Failure Unit Test',html)
|
||||
self.assertIn('Failure Unit Test',text)
|
||||
|
||||
Reference in New Issue
Block a user