1
1
import textwrap
2
2
from unittest import TestCase
3
3
4
+ from redash import settings
4
5
from redash .models import OPERATORS , Alert , db , next_state
5
6
from tests import BaseTestCase
6
7
@@ -153,6 +154,10 @@ def create_alert(self, results, column="foo", value="5"):
153
154
return alert
154
155
155
156
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
156
161
alert = self .create_alert (get_results (1 ))
157
162
custom_alert = """
158
163
<pre>
@@ -176,9 +181,9 @@ def test_render_custom_alert_template(self):
176
181
ALERT_CONDITION equals
177
182
ALERT_THRESHOLD 5
178
183
ALERT_NAME %s
179
- ALERT_URL https :///default /alerts/%d
184
+ ALERT_URL http ://localhost:5001 /alerts/%d
180
185
QUERY_NAME Query
181
- QUERY_URL https :///default /queries/%d
186
+ QUERY_URL http ://localhost:5001 /queries/%d
182
187
QUERY_RESULT_VALUE 1
183
188
QUERY_RESULT_ROWS [{'foo': 1}]
184
189
QUERY_RESULT_COLS [{'name': 'foo', 'type': 'STRING'}]
@@ -190,6 +195,8 @@ def test_render_custom_alert_template(self):
190
195
)
191
196
result = alert .render_template (textwrap .dedent (custom_alert ))
192
197
self .assertMultiLineEqual (result , textwrap .dedent (expected ))
198
+ settings .HOST = old_host
199
+ settings .MULTI_ORG = old_multi_org
193
200
194
201
def test_render_custom_alert_template_query_table (self ):
195
202
alert = self .create_alert (get_results (1 ))
0 commit comments