def test_not_dryrun_only_once_per_week( mock_send_emails, mock_file_bugs, mock_get_version, mock_download_file, mock_scalars_parser, mock_histograms_parser, mock_events_parser, ): mock_file_bugs.return_value = {} mock_events_parser.return_value = {} mock_histograms_parser.return_value = {} mock_scalars_parser.return_value = {} mock_get_version.return_value = "75" for weekday in range(7): base_date = datetime.date(2020, 1, 1) probe_expiry_alert.main(base_date + datetime.timedelta(days=weekday), False, "") mock_file_bugs.assert_has_calls( [mock.call([], "76", "", dryrun=False)] + [mock.call([], "76", "", dryrun=True)] * 6, any_order=True, ) assert mock_file_bugs.call_count == 7 mock_send_emails.assert_has_calls( [mock.call({}, {}, "76", dryrun=False)] + [mock.call({}, {}, "76", dryrun=True)] * 6, any_order=True, ) assert mock_send_emails.call_count == 7
def test_main_run( mock_send_emails, mock_file_bugs, mock_user_exists, mock_get_version, mock_download_file, mock_scalars_parser, mock_histograms_parser, mock_events_parser, ): mock_user_exists.return_value = False mock_events_parser.return_value = { "p1": { "expiry_version": "76", "notification_emails": ["*****@*****.**"], "bug_numbers": [], } } mock_histograms_parser.return_value = { "p2": { "expiry_version": "75", "notification_emails": ["*****@*****.**"], "bug_numbers": [], } } mock_scalars_parser.return_value = { "p3": { "expiry_version": "77", "notification_emails": ["*****@*****.**"], "bug_numbers": [], } } mock_get_version.return_value = "75" probe_expiry_alert.main(datetime.date(2020, 1, 8), False, "") expected_expiring_probes = [ ProbeDetails("p1", "Firefox", "General", [], None) ] mock_file_bugs.assert_called_once_with(expected_expiring_probes, "76", "", dryrun=False)