Skip to content

Commit 038ca94

Browse files
committed
Use fixed environment for TestAlertRenderTemplate
Other tests and local settings sometimes caused this test to fail.
1 parent c0317f8 commit 038ca94

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/models/test_alerts.py

Lines changed: 9 additions & 2 deletions
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

@@ -149,6 +150,10 @@ def create_alert(self, results, column="foo", value="5"):
149150
return alert
150151

151152
def test_render_custom_alert_template(self):
153+
old_host = settings.HOST
154+
old_multi_org = settings.MULTI_ORG
155+
settings.HOST = "http://localhost:5001"
156+
settings.MULTI_ORG = False
152157
alert = self.create_alert(get_results(1))
153158
custom_alert = """
154159
<pre>
@@ -172,9 +177,9 @@ def test_render_custom_alert_template(self):
172177
ALERT_CONDITION equals
173178
ALERT_THRESHOLD 5
174179
ALERT_NAME %s
175-
ALERT_URL https:///default/alerts/%d
180+
ALERT_URL http://localhost:5001/alerts/%d
176181
QUERY_NAME Query
177-
QUERY_URL https:///default/queries/%d
182+
QUERY_URL http://localhost:5001/queries/%d
178183
QUERY_RESULT_VALUE 1
179184
QUERY_RESULT_ROWS [{'foo': 1}]
180185
QUERY_RESULT_COLS [{'name': 'foo', 'type': 'STRING'}]
@@ -186,6 +191,8 @@ def test_render_custom_alert_template(self):
186191
)
187192
result = alert.render_template(textwrap.dedent(custom_alert))
188193
self.assertMultiLineEqual(result, textwrap.dedent(expected))
194+
settings.HOST = old_host
195+
settings.MULTI_ORG = old_multi_org
189196

190197
def test_render_custom_alert_template_query_table(self):
191198
alert = self.create_alert(get_results(1))

0 commit comments

Comments
 (0)