def test_get_manifest_report_not_found(self, log_mock):
     """Test that Azure report is throwing an exception if the report was not found."""
     self.downloader.tracing_id = "1111-2222-4444-5555"
     self.downloader._azure_client.get_latest_cost_export_for_path = Mock(
         side_effect=AzureCostReportNotFound("Oops!"))
     manifest, last_modified = self.downloader._get_manifest(
         self.mock_data.test_date)
     self.assertEqual(manifest, {})
     self.assertEqual(last_modified, None)
     call_arg = log_mock.info.call_args.args[0]
     self.assertEqual(call_arg.get("tracing_id"),
                      self.downloader.tracing_id)
     self.assertTrue("Unable to find manifest" in call_arg.get("message"))
    def get_cost_export_for_key(self, key, container_name):
        """Get exports for key."""
        class ExportProperties:
            etag = self.export_etag

        class Export:
            name = self.export_file

        if key == self.export_key:
            mock_export = ExportProperties()
        else:
            message = f"No cost report for report name {key} found in container {container_name}."
            raise AzureCostReportNotFound(message)
        return mock_export
    def get_latest_cost_export_for_path(self, report_path, container_name):
        """Get exports for path."""
        class BadExport:
            name = self.export_name

        class Export:
            name = self.export_file

        if report_path == self.report_path:
            mock_export = Export()
        elif report_path == self.bad_report_path:
            mock_export = BadExport()
        else:
            message = f"No cost report found in container {container_name} for " f"path {report_path}."
            raise AzureCostReportNotFound(message)
        return mock_export
示例#4
0
def throws_azure_nocosterror():
    """Raise error for testing."""
    raise AzureCostReportNotFound()