本文整理汇总了Python中pulp.plugins.util.metadata_writer.MetadataFileContext.initialize方法的典型用法代码示例。如果您正苦于以下问题:Python MetadataFileContext.initialize方法的具体用法?Python MetadataFileContext.initialize怎么用?Python MetadataFileContext.initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.plugins.util.metadata_writer.MetadataFileContext
的用法示例。
在下文中一共展示了MetadataFileContext.initialize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_initialize_double_call
# 需要导入模块: from pulp.plugins.util.metadata_writer import MetadataFileContext [as 别名]
# 或者: from pulp.plugins.util.metadata_writer.MetadataFileContext import initialize [as 别名]
def test_initialize_double_call(self):
path = os.path.join(self.metadata_file_dir, 'test.xml')
context = MetadataFileContext(path)
context.initialize()
context._write_file_header = Mock()
context.initialize()
self.assertEquals(0, context._write_file_header.call_count)
context.finalize()
示例2: test_finalize_double_call
# 需要导入模块: from pulp.plugins.util.metadata_writer import MetadataFileContext [as 别名]
# 或者: from pulp.plugins.util.metadata_writer.MetadataFileContext import initialize [as 别名]
def test_finalize_double_call(self):
path = os.path.join(self.metadata_file_dir, 'test.xml')
context = MetadataFileContext(path)
context.initialize()
context.finalize()
context._write_file_footer = Mock(side_effect=Exception())
context.finalize()
self.assertEquals(context._write_file_footer.call_count, 0)
示例3: test_finalize_checksum_type_none
# 需要导入模块: from pulp.plugins.util.metadata_writer import MetadataFileContext [as 别名]
# 或者: from pulp.plugins.util.metadata_writer.MetadataFileContext import initialize [as 别名]
def test_finalize_checksum_type_none(self):
path = os.path.join(self.metadata_file_dir, 'test.xml')
context = MetadataFileContext(path)
context.initialize()
context._write_file_footer = Mock()
context.finalize()
context._write_file_footer.assert_called_once_with()
self.assertEqual(context.metadata_file_path, path)
self.assertEqual(context.metadata_file_handle, None)
示例4: test_finalize_error_on_write_footer
# 需要导入模块: from pulp.plugins.util.metadata_writer import MetadataFileContext [as 别名]
# 或者: from pulp.plugins.util.metadata_writer.MetadataFileContext import initialize [as 别名]
def test_finalize_error_on_write_footer(self):
# Ensure that if the write_file_footer throws an exception we eat it so that
# if multiple metadata files are being finalized, one error won't cause open
# file handles on the others
path = os.path.join(self.metadata_file_dir, 'test.xml')
context = MetadataFileContext(path)
context.initialize()
context._write_file_footer = Mock(side_effect=Exception())
context.finalize()
context._write_file_footer.assert_called_once_with()
self.assertEqual(context.metadata_file_path, path)
示例5: test_initialize
# 需要导入模块: from pulp.plugins.util.metadata_writer import MetadataFileContext [as 别名]
# 或者: from pulp.plugins.util.metadata_writer.MetadataFileContext import initialize [as 别名]
def test_initialize(self):
path = os.path.join(self.metadata_file_dir, 'foo', 'header.xml')
context = MetadataFileContext(path)
context._write_file_header = Mock()
context.initialize()
context._write_file_header.assert_called_once_with()
self.assertTrue(os.path.exists(path))
with open(path) as h:
content = h.read()
expected_content = ''
self.assertEqual(content, expected_content)
示例6: test_enter
# 需要导入模块: from pulp.plugins.util.metadata_writer import MetadataFileContext [as 别名]
# 或者: from pulp.plugins.util.metadata_writer.MetadataFileContext import initialize [as 别名]
def test_enter(self):
path = os.path.join(self.metadata_file_dir, 'test.xml')
context = MetadataFileContext(path)
context.initialize = Mock()
context.__enter__()
context.initialize.assert_called_once_with()