def test_import_upload_step_failed(self, render_failure_message):
        """
        Assert that the CLI properly informs the user when an importer reports failure upon
        importing a unit to the repository.
        """
        response_body = {'success_flag': False, 'summary': 'An error message.'}
        response = mock.MagicMock()
        response.response_body = response_body
        response.is_async = mock.MagicMock(return_value=False)
        upload_manager = mock.MagicMock()
        upload_manager.import_upload = mock.MagicMock(return_value=response)
        upload_ids = ['an_id']

        upload.perform_upload(self.context, upload_manager, upload_ids)

        render_failure_message.assert_called_once_with('... failed: %s' % response_body['summary'])
    def test_import_upload_step_succeeded(self, write, render_failure_message):
        """
        Assert that the CLI properly informs the user when an importer reports success upon
        importing a unit to the repository.
        """
        response_body = {'success_flag': True, 'summary': None}
        response = mock.MagicMock()
        response.response_body = response_body
        response.is_async = mock.MagicMock(return_value=False)
        upload_manager = mock.MagicMock()
        upload_manager.import_upload = mock.MagicMock(return_value=response)
        upload_ids = ['an_id']

        upload.perform_upload(self.context, upload_manager, upload_ids)

        write.assert_any_call('... completed', tag='import_upload_success')
        # No errors should have been rendered
        self.assertEqual(render_failure_message.call_count, 0)