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()
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()
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()
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()
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()
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()
def test_prepare_no_accounts(self, mock_downloader, mock_accounts_accessor): """Test downloading cost usage reports.""" orchestrator = Orchestrator() reports = orchestrator.prepare() self.assertIsNone(reports)
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()
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)
def check_report_updates(): """Scheduled task to initiate scanning process on a regular interval.""" orchestrator = Orchestrator() orchestrator.prepare()
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)})
def test_prepare(self, mock_downloader, mock_task): """Test downloading cost usage reports.""" orchestrator = Orchestrator() reports = orchestrator.prepare() self.assertTrue(reports)