Skip to content

Commit

Permalink
fix old keys implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
eschutho committed May 27, 2022
1 parent 2bfdb1b commit 0deb744
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
2 changes: 1 addition & 1 deletion scripts/tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,5 @@ fi

if [ $RUN_TESTS -eq 1 ]
then
pytest --durations=0 --maxfail=10 "${TEST_MODULE}"
pytest --durations=0 --maxfail=1 "${TEST_MODULE}"
fi
5 changes: 0 additions & 5 deletions superset/explore/form_data/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ def run(self) -> bool:
contextual_key = cache_key(
session.get("_id"), tab_id, datasource_id, chart_id, datasource_type
)
if contextual_key is None:
# check again with old keys
contextual_key = cache_key(
session.get("_id"), tab_id, datasource_id, chart_id
)
cache_manager.explore_form_data_cache.delete(contextual_key)
return cache_manager.explore_form_data_cache.delete(key)
return False
Expand Down
5 changes: 0 additions & 5 deletions superset/explore/form_data/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ def run(self) -> Optional[str]:
contextual_key = cache_key(
session.get("_id"), tab_id, datasource_id, chart_id, datasource_type
)
if contextual_key is None:
# check again with old keys
contextual_key = cache_key(
session.get("_id"), tab_id, datasource_id, chart_id
)
key = cache_manager.explore_form_data_cache.get(contextual_key)
if not key or not tab_id:
key = random_key()
Expand Down
36 changes: 36 additions & 0 deletions tests/integration_tests/explore/form_data/commands_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from superset.connectors.sqla.models import SqlaTable
from superset.explore.form_data.commands.create import CreateFormDataCommand
from superset.explore.form_data.commands.parameters import CommandParameters
from superset.explore.form_data.commands.update import UpdateFormDataCommand
from superset.models.slice import Slice
from superset.utils.core import DatasourceType, get_example_default_schema
from superset.utils.database import get_example_database
Expand Down Expand Up @@ -92,3 +93,38 @@ def test_create_form_data_command(self, mock_g):
command = CreateFormDataCommand(args)

assert isinstance(command.run(), str)


# TODO
# @patch("superset.security.manager.g")
# @pytest.mark.usefixtures("create_dataset", "create_slice")
# def test_update_form_data_command(self, mock_g):
# mock_g.user = security_manager.find_user("admin")

# dataset = (
# db.session.query(SqlaTable).filter_by(
# table_name="dummy_sql_table").first()
# )
# slice = db.session.query(Slice).filter_by(
# slice_name="slice_name").first()
# create_args = CommandParameters(
# actor=mock_g.user,
# datasource_id=dataset.id,
# datasource_type=DatasourceType.TABLE,
# chart_id=slice.id,
# tab_id=1,
# form_data="",
# )
# key = CreateFormDataCommand(create_args)
# update_args = CommandParameters(
# actor=mock_g.user,
# datasource_id=dataset.id,
# datasource_type=DatasourceType.TABLE,
# chart_id=slice.id,
# tab_id=1,
# form_data="",
# key=key
# )
# command = UpdateFormDataCommand(update_args)

# assert isinstance(command.run(), str)

0 comments on commit 0deb744

Please sign in to comment.