mikebridge commented on code in PR #39973:
URL: https://github.com/apache/superset/pull/39973#discussion_r3573707415
##########
tests/unit_tests/commands/report/execute_test.py:
##########
@@ -2359,3 +2359,32 @@ def
test_get_dashboard_urls_raises_when_target_dashboard_soft_deleted(
state = BaseReportState(report_schedule, datetime.utcnow(), uuid4())
with pytest.raises(ReportScheduleTargetDashboardDeletedError):
state.get_dashboard_urls()
+
+
+def test_get_url_raises_unexpected_error_when_target_is_missing(
+ mocker: MockerFixture,
+ app: SupersetApp,
+) -> None:
+ """A malformed schedule without either target raises a useful error."""
+ mock_report_schedule: ReportSchedule = mocker.Mock(spec=ReportSchedule)
+ mock_report_schedule.id = 42
+ mock_report_schedule.name = "orphan_report"
+ mock_report_schedule.chart = None
+ mock_report_schedule.chart_id = None
+ mock_report_schedule.dashboard = None
+ mock_report_schedule.dashboard_id = None
+ mock_report_schedule.force_screenshot = False
+
+ class_instance: BaseReportState = BaseReportState(
+ mock_report_schedule, "January 1, 2021", "execution_id_example"
+ )
+ class_instance._report_schedule = mock_report_schedule
+
+ with pytest.raises(ReportScheduleUnexpectedError) as excinfo:
+ class_instance._get_url()
+
+ message = str(excinfo.value)
Review Comment:
Addressed in 736584562: the local is explicitly annotated as `message: str`.
The focused test module passes all 77 tests, and all applicable PR-file
pre-commit hooks pass.
--
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]