mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
chore: Migrate warm up cache endpoint to api v1 (#23853)
This commit is contained in:
@@ -31,13 +31,20 @@ from superset.datasets.commands.create import CreateDatasetCommand
|
||||
from superset.datasets.commands.exceptions import (
|
||||
DatasetInvalidError,
|
||||
DatasetNotFoundError,
|
||||
WarmUpCacheTableNotFoundError,
|
||||
)
|
||||
from superset.datasets.commands.export import ExportDatasetsCommand
|
||||
from superset.datasets.commands.importers import v0, v1
|
||||
from superset.datasets.commands.warm_up_cache import DatasetWarmUpCacheCommand
|
||||
from superset.models.core import Database
|
||||
from superset.models.slice import Slice
|
||||
from superset.utils.core import get_example_default_schema
|
||||
from superset.utils.database import get_example_database
|
||||
from tests.integration_tests.base_tests import SupersetTestCase
|
||||
from tests.integration_tests.fixtures.birth_names_dashboard import (
|
||||
load_birth_names_dashboard_with_slices,
|
||||
load_birth_names_data,
|
||||
)
|
||||
from tests.integration_tests.fixtures.energy_dashboard import (
|
||||
load_energy_table_data,
|
||||
load_energy_table_with_slice,
|
||||
@@ -575,3 +582,28 @@ class TestCreateDatasetCommand(SupersetTestCase):
|
||||
with examples_db.get_sqla_engine_with_context() as engine:
|
||||
engine.execute("DROP TABLE test_create_dataset_command")
|
||||
db.session.commit()
|
||||
|
||||
|
||||
class TestDatasetWarmUpCacheCommand(SupersetTestCase):
|
||||
def test_warm_up_cache_command_table_not_found(self):
|
||||
with self.assertRaises(WarmUpCacheTableNotFoundError):
|
||||
DatasetWarmUpCacheCommand("not", "here", None, None).run()
|
||||
|
||||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
|
||||
def test_warm_up_cache(self):
|
||||
birth_table = self.get_birth_names_dataset()
|
||||
birth_charts = (
|
||||
db.session.query(Slice)
|
||||
.filter(
|
||||
Slice.datasource_id == birth_table.id, Slice.datasource_type == "table"
|
||||
)
|
||||
.all()
|
||||
)
|
||||
results = DatasetWarmUpCacheCommand(
|
||||
get_example_database().database_name, "birth_names", None, None
|
||||
).run()
|
||||
self.assertEqual(len(results), len(birth_charts))
|
||||
for chart_result in results:
|
||||
assert "chart_id" in chart_result
|
||||
assert "viz_error" in chart_result
|
||||
assert "viz_status" in chart_result
|
||||
|
||||
Reference in New Issue
Block a user