Пример #1
0
    def test_attempt_download_report_raise_normal_exception(self):
        """When we see an exception other than AdwordsReportBadRequestError in attempt_download_report, we expect that error to be raised with no special handling
        We also expect that it will retry 3 times"""
        mocked_report_downloader = Mock()
        mocked_report_downloader.DownloadReportAsStream = Mock(side_effect=Exception(
            "this is a normal exception"
        ))

        with self.assertRaisesRegexp(Exception, "this is a normal exception") as e:
            attempt_download_report(mocked_report_downloader, "")
        self.assertEquals(3, mocked_report_downloader.DownloadReportAsStream.call_count)
Пример #2
0
    def test_attempt_download_report_raise(self):
        """When AdWordsReportBadRequestError is returned in attempt_download_report, we expect the following custom error message.
        We also expect that it will retry 3 times"""
        mocked_report_downloader = Mock()
        mocked_report_downloader.DownloadReportAsStream = Mock(side_effect=AdWordsReportBadRequestError(
            "RateExceededError.RATE_EXCEEDED",
            'Basic Access Daily Reporting Quota',
            'None'"",
            "",
            "",
            ""
        ))

        with self.assertRaisesRegexp(Exception, "Rate Exceeded Error. Too many requests were made to the API in a short period of time.") as e:
            attempt_download_report(mocked_report_downloader, "")
        self.assertEquals(3, mocked_report_downloader.DownloadReportAsStream.call_count)
Пример #3
0
    def test_attempt_download_report_raise_for_other_AdWordsReportBadRequestError(self):
        """When AdWordsReportBadRequestError is returned without 'rate exceeded' message in attempt_download_report, we expect to not see a custom error message.
        We also expect that it will retry 3 times"""
        mocked_report_downloader = Mock()
        mocked_report_downloader.DownloadReportAsStream = Mock(side_effect=AdWordsReportBadRequestError(
            "this is a non 'rate exceeded' AdWordsReportBadRequestError",
            'Basic Access Daily Reporting Quota',
            'None'"",
            "",
            "",
            ""
        ))

        with self.assertRaisesRegexp(Exception, "this is a non 'rate exceeded' AdWordsReportBadRequestError") as e:
            attempt_download_report(mocked_report_downloader, "")
        self.assertEquals(3, mocked_report_downloader.DownloadReportAsStream.call_count)