Skip to content

Commit

Permalink
Use saved values for parameters in scheduled queries (re #43)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Short authored and jezdez committed Mar 5, 2018
1 parent b4a8d5c commit a7b4f46
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/tasks/test_refresh_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,23 @@ def test_doesnt_enqueue_outdated_queries_for_paused_data_source(self):
add_job_mock.assert_called_with(
query.query_text, query.data_source, query.user_id,
scheduled_query=query, metadata=ANY)

def test_enqueues_parameterized_queries(self):
"""
Scheduled queries with parameters use saved values.
"""
query = self.factory.create_query(
query_text="select {{n}}",
options={"parameters": [{
"global": False,
"type": "text",
"name": "n",
"value": "42",
"title": "n"}]})
oq = staticmethod(lambda: [query])
with patch('redash.tasks.queries.enqueue_query') as add_job_mock, \
patch.object(Query, 'outdated_queries', oq):
refresh_queries()
add_job_mock.assert_called_with(
"select 42", query.data_source, query.user_id,
scheduled_query=query, metadata=ANY)

0 comments on commit a7b4f46

Please sign in to comment.