sadpandajoe commented on code in PR #43575: URL: https://github.com/apache/superset/pull/43575#discussion_r3931080732
########## tests/unit_tests/commands/dashboard/update_test.py: ########## @@ -0,0 +1,82 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from unittest.mock import MagicMock, patch, PropertyMock + +from superset.commands.dashboard.update import UpdateDashboardCommand +from superset.utils import json + + +def test_process_tab_diff_ignores_the_layout_without_position_json( + app_context: None, +) -> None: + """An update that does not carry a layout must not walk the stored one. + + A tab can only be deleted by an update that supplies `position_json`, so + for any other payload — publishing a dashboard, renaming it — there is + nothing to diff and the stored layout must be left alone. + """ + command = UpdateDashboardCommand(1, {"published": True}) + tabs = PropertyMock(side_effect=AssertionError("the layout must not be read")) + model = MagicMock() + type(model).tabs = tabs + command._model = model # noqa: SLF001 + + command.process_tab_diff() + + tabs.assert_not_called() + + +def test_process_tab_diff_deactivates_reports_on_deleted_tabs( Review Comment: The new coverage only mocks `tabs` and calls `process_tab_diff` directly, so it does not exercise the reported persisted-corruption → repair-request path. A JSON-parseable layout with a dangling child can still be stored before this change; could we add the two-step API regression that stores it, then updates it with a corrected `position_json` and asserts the repair returns 200 and persists? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
