mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix(chart): deprecate persisting url_params (#18960)
* fix(chart): deprecate peristing url_params
* remove duplicated backend logic
* use omitBy
* simplify omit
(cherry picked from commit bd63a1bd98)
This commit is contained in:
committed by
Ville Brofeldt
parent
3c90220cf6
commit
6d2b583fee
@@ -15,7 +15,6 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import json
|
||||
from datetime import datetime
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
@@ -23,6 +22,7 @@ import yaml
|
||||
from flask import g
|
||||
|
||||
from superset import db, security_manager
|
||||
from superset.charts.commands.create import CreateChartCommand
|
||||
from superset.charts.commands.exceptions import ChartNotFoundError
|
||||
from superset.charts.commands.export import ExportChartsCommand
|
||||
from superset.charts.commands.importers.v1 import ImportChartsCommand
|
||||
@@ -329,6 +329,36 @@ class TestImportChartsCommand(SupersetTestCase):
|
||||
}
|
||||
|
||||
|
||||
class TestChartsCreateCommand(SupersetTestCase):
|
||||
@patch("superset.views.base.g")
|
||||
@patch("superset.security.manager.g")
|
||||
@pytest.mark.usefixtures("load_energy_table_with_slice")
|
||||
def test_create_v1_response(self, mock_sm_g, mock_g):
|
||||
"""Test that the create chart command creates a chart"""
|
||||
actor = security_manager.find_user(username="admin")
|
||||
mock_g.user = mock_sm_g.user = actor
|
||||
chart_data = {
|
||||
"slice_name": "new chart",
|
||||
"description": "new description",
|
||||
"owners": [actor.id],
|
||||
"viz_type": "new_viz_type",
|
||||
"params": json.dumps({"viz_type": "new_viz_type"}),
|
||||
"cache_timeout": 1000,
|
||||
"datasource_id": 1,
|
||||
"datasource_type": "table",
|
||||
}
|
||||
command = CreateChartCommand(actor, chart_data)
|
||||
chart = command.run()
|
||||
chart = db.session.query(Slice).get(chart.id)
|
||||
assert chart.viz_type == "new_viz_type"
|
||||
json_params = json.loads(chart.params)
|
||||
assert json_params == {"viz_type": "new_viz_type"}
|
||||
assert chart.slice_name == "new chart"
|
||||
assert chart.owners == [actor]
|
||||
db.session.delete(chart)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
class TestChartsUpdateCommand(SupersetTestCase):
|
||||
@patch("superset.views.base.g")
|
||||
@patch("superset.security.manager.g")
|
||||
|
||||
Reference in New Issue
Block a user