Example #1
0
    def test_prepare_w_exception(self, mock_task, mock_labeler, mock_inspect):
        """Test that Orchestrator.prepare() handles broad exceptions."""

        orchestrator = Orchestrator()
        orchestrator.prepare()
        mock_task.assert_called()
        mock_labeler.assert_not_called()
Example #2
0
 def test_prepare_w_no_manifest_found(self, mock_task, mock_labeler,
                                      mock_inspect):
     """Test that Orchestrator.prepare() is skipped when no manifest is found."""
     orchestrator = Orchestrator()
     orchestrator.prepare()
     mock_task.assert_not_called()
     mock_labeler.assert_not_called()
Example #3
0
    def test_prepare_w_status_backoff(self, mock_task, mock_accessor):
        """Test that Orchestrator.prepare() is skipped when backing off."""
        mock_accessor.is_valid.return_value = False
        mock_accessor.is_backing_off.return_value = True

        orchestrator = Orchestrator()
        orchestrator.prepare()
        mock_task.assert_not_called()
Example #4
0
    def test_prepare_w_downloader_error(self, mock_task, mock_labeler,
                                        mock_inspect):
        """Test that Orchestrator.prepare() handles downloader errors."""

        orchestrator = Orchestrator()
        orchestrator.prepare()
        mock_task.assert_called()
        mock_labeler.assert_not_called()
Example #5
0
    def test_prepare_w_manifest_processing_successful(self, mock_task,
                                                      mock_labeler,
                                                      mock_inspect):
        """Test that Orchestrator.prepare() works when manifest processing is successful."""
        mock_labeler().get_label_details.return_value = (True, True)

        orchestrator = Orchestrator()
        orchestrator.prepare()
        mock_labeler.assert_called()
Example #6
0
    def test_prepare_w_status_valid(self, mock_task, mock_accessor, mock_labeler):
        """Test that Orchestrator.prepare() works when status is valid."""
        mock_labeler().get_label_details.return_value = (True, True)

        mock_accessor().is_valid.return_value = True
        mock_accessor().is_backing_off.return_value = False

        orchestrator = Orchestrator()
        orchestrator.prepare()
        mock_task.assert_called()
Example #7
0
    def test_prepare_no_accounts(self, mock_downloader,
                                 mock_accounts_accessor):
        """Test downloading cost usage reports."""
        orchestrator = Orchestrator()
        reports = orchestrator.prepare()

        self.assertIsNone(reports)
Example #8
0
    def test_prepare_no_accounts(self, mock_downloader, mock_accounts_accessor,
                                 mock_inspect, mock_account_labler):
        """Test downloading cost usage reports."""
        orchestrator = Orchestrator()
        reports = orchestrator.prepare()

        self.assertIsNone(reports)
        mock_account_labler.assert_not_called()
Example #9
0
def post_notification():
    """Packages response for class-based view."""
    header_list = request.headers.to_wsgi_list()
    body = request.data.decode('utf-8')
    logger.debug('Received Header: %s', str(request.headers))
    logger.debug('Received Body: %s', str(body))
    notified_billing_source = None
    try:
        handler = NotificationHandler(header_list, body)
        notified_billing_source = handler.billing_source()
    except NotificationHandlerError as error:
        logger.error(str(error))
    except NotificationHandlerFilter as info:
        logger.info(str(info))

    if notified_billing_source:
        orchestrator = Orchestrator(notified_billing_source)
        orchestrator.prepare()

    return ('', 204)
Example #10
0
def check_report_updates():
    """Scheduled task to initiate scanning process on a regular interval."""
    orchestrator = Orchestrator()
    orchestrator.prepare()
Example #11
0
def download_report():
    """Return download file async task ID."""
    orchestrator = Orchestrator()
    async_download_result = orchestrator.prepare()
    return jsonify({'Download Request Task ID': str(async_download_result)})
Example #12
0
    def test_prepare(self, mock_downloader, mock_task):
        """Test downloading cost usage reports."""
        orchestrator = Orchestrator()

        reports = orchestrator.prepare()
        self.assertTrue(reports)