mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
fix: Support Jinja template functions in global async queries (#16412)
* Support Jinja template functions in async queries * Pylint * Add tests for async tasks * Remove redundant has_request_context check
This commit is contained in:
@@ -45,7 +45,8 @@ from tests.integration_tests.test_app import app
|
||||
class TestAsyncQueries(SupersetTestCase):
|
||||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
|
||||
@mock.patch.object(async_query_manager, "update_job")
|
||||
def test_load_chart_data_into_cache(self, mock_update_job):
|
||||
@mock.patch.object(async_queries, "set_form_data")
|
||||
def test_load_chart_data_into_cache(self, mock_set_form_data, mock_update_job):
|
||||
async_query_manager.init_app(app)
|
||||
query_context = get_query_context("birth_names")
|
||||
user = security_manager.find_user("gamma")
|
||||
@@ -63,6 +64,7 @@ class TestAsyncQueries(SupersetTestCase):
|
||||
load_chart_data_into_cache(job_metadata, query_context)
|
||||
|
||||
ensure_user_is_set.assert_called_once_with(user.id)
|
||||
mock_set_form_data.assert_called_once_with(query_context)
|
||||
mock_update_job.assert_called_once_with(
|
||||
job_metadata, "done", result_url=mock.ANY
|
||||
)
|
||||
@@ -154,7 +156,10 @@ class TestAsyncQueries(SupersetTestCase):
|
||||
)
|
||||
|
||||
@mock.patch.object(async_query_manager, "update_job")
|
||||
def test_load_explore_json_into_cache_error(self, mock_update_job):
|
||||
@mock.patch.object(async_queries, "set_form_data")
|
||||
def test_load_explore_json_into_cache_error(
|
||||
self, mock_set_form_data, mock_update_job
|
||||
):
|
||||
async_query_manager.init_app(app)
|
||||
user = security_manager.find_user("gamma")
|
||||
form_data = {}
|
||||
@@ -173,6 +178,7 @@ class TestAsyncQueries(SupersetTestCase):
|
||||
load_explore_json_into_cache(job_metadata, form_data)
|
||||
ensure_user_is_set.assert_called_once_with(user.id)
|
||||
|
||||
mock_set_form_data.assert_called_once_with(form_data)
|
||||
errors = ["The dataset associated with this chart no longer exists"]
|
||||
mock_update_job.assert_called_once_with(job_metadata, "error", errors=errors)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user