codeant-ai-for-open-source[bot] commented on code in PR #34880: URL: https://github.com/apache/superset/pull/34880#discussion_r3502579608
########## tests/unit_tests/commands/dashboard/importers/v1/assets_test.py: ########## @@ -0,0 +1,200 @@ +# 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. + +import copy + +from pytest_mock import MockerFixture +from sqlalchemy.orm.session import Session + +from tests.unit_tests.fixtures.assets_configs import ( + charts_config_1, + dashboards_config_1, + databases_config, + datasets_config, +) + + +def test_import_dashboard_overwrite_charts_and_datasets( + mocker: MockerFixture, session: Session +) -> None: + """ + Test that existing dashboards are overwritten. + """ + import time + + from superset import db, security_manager + from superset.commands.dashboard.importers.v1 import ImportDashboardsCommand + from superset.connectors.sqla.models import SqlaTable + from superset.models.dashboard import Dashboard + from superset.models.slice import Slice + + mocker.patch.object(security_manager, "can_access", return_value=True) + + engine = db.session.get_bind() + Dashboard.metadata.create_all(engine) + + # for some reason it won't allow me to reuse the same config in the second import + # thus declaring two configs with the same content + base_configs = { + **copy.deepcopy(databases_config), + **copy.deepcopy(datasets_config), + **copy.deepcopy(charts_config_1), + **copy.deepcopy(dashboards_config_1), + } + new_configs = { + **copy.deepcopy(databases_config), + **copy.deepcopy(datasets_config), + **copy.deepcopy(charts_config_1), + **copy.deepcopy(dashboards_config_1), + } + + # gettings uuids Review Comment: **Suggestion:** The local variable name is misspelled (`dasboard`), which makes the test harder to read and search; rename it to `dashboard_configs` consistently in both tests. [typo] <details> <summary><b>Severity Level:</b> Minor ๐งน</summary> ```mdx - โ ๏ธ Misspelled variable harms test readability and searchability. - โ ๏ธ Suggestion addresses stylistic issue; no functional impact. ``` </details> <details> <summary><b>Steps of Reproduction โ </b></summary> ```mdx 1. Open the test module `tests/unit_tests/commands/dashboard/importers/v1/assets_test.py:31-200` which exercises the `ImportDashboardsCommand._import()` behavior for overwriting charts and datasets. 2. At line 65 in `test_import_dashboard_overwrite_charts_and_datasets`, observe the local variable declaration `dasboard_configs = list(dashboards_config_1.values())`, and similarly at line 154 in `test_import_dashboard_do_not_overwrite_charts_and_datasets`, where the same misspelling is used. 3. Confirm that `dasboard_configs` is immediately consumed to compute `dashboard_uuid` at lines 67 and 155, and that the typo does not affect test correctness because the name is consistently misspelled and used only locally. 4. Note that the identifier differs from the correctly spelled `dashboard_config` pattern, making these tests slightly harder to search and read; fixing the typo to `dashboard_configs` is a stylistic improvement with no runtime or functional impact, so this suggestion is about readability rather than a behavioral bug. ``` </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=cdc9e8cce32e48b88828d472c317254a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=cdc9e8cce32e48b88828d472c317254a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) *(Use Cmd/Ctrl + Click for best experience)* <details> <summary><b>Prompt for AI Agent ๐ค </b></summary> ```mdx This is a comment left during a code review. **Path:** tests/unit_tests/commands/dashboard/importers/v1/assets_test.py **Line:** 65:65 **Comment:** *Typo: The local variable name is misspelled (`dasboard`), which makes the test harder to read and search; rename it to `dashboard_configs` consistently in both tests. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F34880&comment_hash=e1d4bc498f8d73373c6479787279ddb5773e7ece2d0c839eb28937b9a40c52a9&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F34880&comment_hash=e1d4bc498f8d73373c6479787279ddb5773e7ece2d0c839eb28937b9a40c52a9&reaction=dislike'>๐</a> -- 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]
