FrancescoCastaldi commented on code in PR #44358:
URL: https://github.com/apache/superset/pull/44358#discussion_r4132220692
##########
tests/unit_tests/commands/chart/create_test.py:
##########
@@ -269,3 +270,114 @@ def
test_create_chart_query_context_without_datasource_is_allowed(
_mock_table_datasource(mocker)
CreateChartCommand(_create_payload(query_context)).validate()
+
+
+def test_create_chart_updates_dashboard_changed_on(mocker: MockerFixture) ->
None:
+ """Issue #44305: Creating a chart linked to dashboards must touch audit
metadata."""
+ _mock_table_datasource(mocker)
+ user = MagicMock()
+ g.user = user
+
+ dashboard = MagicMock(is_managed_externally=False, changed_on=None,
changed_by=None)
+ mocker.patch(
+ "superset.commands.chart.create.DashboardDAO.find_by_ids",
+ return_value=[dashboard],
+ )
+ mocker.patch(
+ "superset.commands.chart.create.security_manager.is_editor",
+ return_value=True,
+ )
+ mocker.patch(
+ "superset.commands.chart.create.ChartDAO.create",
+ return_value=MagicMock(),
+ )
+
+ cmd = CreateChartCommand(
+ {
+ "datasource_id": 42,
+ "datasource_type": "table",
+ "slice_name": "New Chart",
+ "viz_type": "table",
+ "dashboards": [101],
+ }
+ )
+ cmd.run()
+
+ assert dashboard.changed_on is not None
Review Comment:
Done in 60c753c: all the touch tests now seed a prior `changed_on`
(`datetime(2020, 1, 1)`) and assert the value advanced after the command runs;
dashboards that must stay untouched assert their `changed_on` still equals the
seed, so a stale or fixed timestamp can no longer slip through. Applied across
the create and update command tests.
--
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]