Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fixed environment for TestAlertRenderTemplate #7260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions tests/models/test_alerts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import textwrap
from unittest import TestCase

from redash import settings
from redash.models import OPERATORS, Alert, db, next_state
from tests import BaseTestCase

Expand Down Expand Up @@ -153,6 +154,10 @@ def create_alert(self, results, column="foo", value="5"):
return alert

def test_render_custom_alert_template(self):
old_host = settings.HOST
old_multi_org = settings.MULTI_ORG
settings.HOST = "http://localhost:5001"
settings.MULTI_ORG = False
alert = self.create_alert(get_results(1))
custom_alert = """
<pre>
Expand All @@ -176,9 +181,9 @@ def test_render_custom_alert_template(self):
ALERT_CONDITION equals
ALERT_THRESHOLD 5
ALERT_NAME %s
ALERT_URL https:///default/alerts/%d
ALERT_URL http://localhost:5001/alerts/%d
QUERY_NAME Query
QUERY_URL https:///default/queries/%d
QUERY_URL http://localhost:5001/queries/%d
QUERY_RESULT_VALUE 1
QUERY_RESULT_ROWS [{'foo': 1}]
QUERY_RESULT_COLS [{'name': 'foo', 'type': 'STRING'}]
Expand All @@ -190,6 +195,8 @@ def test_render_custom_alert_template(self):
)
result = alert.render_template(textwrap.dedent(custom_alert))
self.assertMultiLineEqual(result, textwrap.dedent(expected))
settings.HOST = old_host
settings.MULTI_ORG = old_multi_org

def test_render_custom_alert_template_query_table(self):
alert = self.create_alert(get_results(1))
Expand Down
Loading