Skip to content

Commit f67b723

Browse files
committed
Use fixed environment for TestAlertRenderTemplate
Other tests and local settings sometimes caused this test to fail.
1 parent 89d7f54 commit f67b723

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/models/test_alerts.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import textwrap
22
from unittest import TestCase
33

4+
from redash import settings
45
from redash.models import OPERATORS, Alert, db, next_state
56
from tests import BaseTestCase
67

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

155156
def test_render_custom_alert_template(self):
157+
old_host = settings.HOST
158+
old_multi_org = settings.MULTI_ORG
159+
settings.HOST = "http://localhost:5001"
160+
settings.MULTI_ORG = False
156161
alert = self.create_alert(get_results(1))
157162
custom_alert = """
158163
<pre>
@@ -176,9 +181,9 @@ def test_render_custom_alert_template(self):
176181
ALERT_CONDITION equals
177182
ALERT_THRESHOLD 5
178183
ALERT_NAME %s
179-
ALERT_URL https:///default/alerts/%d
184+
ALERT_URL http://localhost:5001/alerts/%d
180185
QUERY_NAME Query
181-
QUERY_URL https:///default/queries/%d
186+
QUERY_URL http://localhost:5001/queries/%d
182187
QUERY_RESULT_VALUE 1
183188
QUERY_RESULT_ROWS [{'foo': 1}]
184189
QUERY_RESULT_COLS [{'name': 'foo', 'type': 'STRING'}]
@@ -190,6 +195,8 @@ def test_render_custom_alert_template(self):
190195
)
191196
result = alert.render_template(textwrap.dedent(custom_alert))
192197
self.assertMultiLineEqual(result, textwrap.dedent(expected))
198+
settings.HOST = old_host
199+
settings.MULTI_ORG = old_multi_org
193200

194201
def test_render_custom_alert_template_query_table(self):
195202
alert = self.create_alert(get_results(1))

0 commit comments

Comments
 (0)