本文整理汇总了Python中nectar.report.DownloadReport.error_msg方法的典型用法代码示例。如果您正苦于以下问题:Python DownloadReport.error_msg方法的具体用法?Python DownloadReport.error_msg怎么用?Python DownloadReport.error_msg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nectar.report.DownloadReport
的用法示例。
在下文中一共展示了DownloadReport.error_msg方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__raise_path_error_not_found
# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import error_msg [as 别名]
def test__raise_path_error_not_found(self):
"""
For a standard error like 404, the report's error message should be used.
"""
report = DownloadReport('http://foo/bar', '/a/b/c')
report.error_report = {'response_code': httplib.NOT_FOUND}
report.error_msg = 'oops'
with self.assertRaises(IOError) as assertion:
registry.V2Repository._raise_path_error(report)
self.assertEqual(assertion.exception.message, report.error_msg)
示例2: test_retrieve_metadata_with_error
# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import error_msg [as 别名]
def test_retrieve_metadata_with_error(self, mock_downloader_download, mock_listener_constructor):
# Setup
mock_listener = mock.MagicMock()
report = DownloadReport(None, None)
report.error_msg = 'oops'
mock_listener.failed_reports = [report]
mock_listener_constructor.return_value = mock_listener
# Test
try:
self.downloader.retrieve_metadata(self.mock_progress_report)
self.fail()
except exceptions.FileRetrievalException:
pass
示例3: test_download_failed_during_iso_download
# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import error_msg [as 别名]
def test_download_failed_during_iso_download(self, _logger):
self.iso_sync_run.progress_report._state = SyncProgressReport.STATE_ISOS_IN_PROGRESS
url = 'http://www.theonion.com/articles/american-airlines-us-airways-merge-to-form' \
'-worlds,31302/'
iso = models.ISO('test.txt', 217,
'a1552efee6f04012bc7e1f3e02c00c6177b08217cead958c47ec83cb8f97f835')
report = DownloadReport(url, '/fake/destination', iso)
report.error_msg = 'uh oh'
self.iso_sync_run.download_failed(report)
self.assertEqual(_logger.error.call_count, 1)
log_msg = _logger.error.mock_calls[0][1][0]
self.assertTrue('uh oh' in log_msg)
示例4: test_retrieve_module_missing_module
# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import error_msg [as 别名]
def test_retrieve_module_missing_module(self, mock_downloader_download, mock_listener_constructor):
# Setup
mock_listener = mock.MagicMock()
report = DownloadReport(None, None)
report.error_msg = 'oops'
mock_listener.failed_reports = [report]
mock_listener_constructor.return_value = mock_listener
# Test
try:
self.downloader.retrieve_module(self.mock_progress_report, self.module)
self.fail()
except exceptions.FileRetrievalException:
expected_filename = web._create_download_tmp_dir(self.working_dir)
expected_filename = os.path.join(expected_filename, self.module.filename())
self.assertFalse(os.path.exists(os.path.join(expected_filename)))
示例5: test_download_failed_during_manifest
# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import error_msg [as 别名]
def test_download_failed_during_manifest(self, _logger):
self.iso_sync_run.progress_report._state = SyncProgressReport.STATE_MANIFEST_IN_PROGRESS
url = 'http://www.theonion.com/articles/' + \
'american-airlines-us-airways-merge-to-form-worlds,31302/'
report = DownloadReport(url, '/fake/destination')
report.error_report = {'why': 'because'}
report.error_msg = 'uh oh'
self.iso_sync_run.download_failed(report)
# The manifest_state should be failed
self.assertEqual(self.iso_sync_run.progress_report._state,
SyncProgressReport.STATE_MANIFEST_FAILED)
self.assertEqual(self.iso_sync_run.progress_report.error_message, report.error_report)
self.assertEqual(_logger.error.call_count, 1)
log_msg = _logger.error.mock_calls[0][1][0]
self.assertTrue('uh oh' in log_msg)
示例6: test__raise_path_error_unathorized
# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import error_msg [as 别名]
def test__raise_path_error_unathorized(self):
"""
Specifically for a 401, a custom error message should be used explaining that the cause
could be either that the client is unauthorized, or that the resource was not found.
Docker hub responds 401 for the not found case, which is why this function exists.
"""
report = DownloadReport('http://foo/bar', '/a/b/c')
report.error_report = {'response_code': httplib.UNAUTHORIZED}
report.error_msg = 'oops'
with self.assertRaises(IOError) as assertion:
registry.V2Repository._raise_path_error(report)
# not worrying about what the exact contents are; just that the function added its
# own message
self.assertNotEqual(assertion.exception.message, report.error_msg)
self.assertTrue(len(assertion.exception.message) > 0)
示例7: test_retrieve_module_missing_module
# 需要导入模块: from nectar.report import DownloadReport [as 别名]
# 或者: from nectar.report.DownloadReport import error_msg [as 别名]
def test_retrieve_module_missing_module(self, mock_downloader_download, mock_listener_constructor):
# Setup
self.module.author = 'asdf'
self.module.puppet_standard_filename.return_value = 'puppet-filename.tar.gz'
mock_listener = mock.MagicMock()
report = DownloadReport(None, None)
report.error_msg = 'oops'
mock_listener.failed_reports = [report]
mock_listener_constructor.return_value = mock_listener
# Test
try:
self.downloader.retrieve_module(self.mock_progress_report, self.module)
self.fail()
except exceptions.FileRetrievalException:
expected_filename = web._create_download_tmp_dir(self.working_dir)
expected_filename = os.path.join(expected_filename, self.module.filename())