当前位置: 首页>>代码示例>>Python>>正文


Python MetadataFileContext._write_file_header方法代码示例

本文整理汇总了Python中pulp.plugins.util.metadata_writer.MetadataFileContext._write_file_header方法的典型用法代码示例。如果您正苦于以下问题:Python MetadataFileContext._write_file_header方法的具体用法?Python MetadataFileContext._write_file_header怎么用?Python MetadataFileContext._write_file_header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pulp.plugins.util.metadata_writer.MetadataFileContext的用法示例。


在下文中一共展示了MetadataFileContext._write_file_header方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_finalize_error_on_close

# 需要导入模块: from pulp.plugins.util.metadata_writer import MetadataFileContext [as 别名]
# 或者: from pulp.plugins.util.metadata_writer.MetadataFileContext import _write_file_header [as 别名]
    def test_finalize_error_on_close(self, mock_logger):

        path = os.path.join(self.metadata_file_dir, 'test.xml')
        context = MetadataFileContext(path)
        context._close_metadata_file_handle = Mock(side_effect=Exception('foo'))

        context._open_metadata_file_handle()
        context._write_file_header()

        context.finalize()

        self.assertTrue(mock_logger.called)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:14,代码来源:test_metadata_writer.py

示例2: test_finalize_with_valid_checksum_type

# 需要导入模块: from pulp.plugins.util.metadata_writer import MetadataFileContext [as 别名]
# 或者: from pulp.plugins.util.metadata_writer.MetadataFileContext import _write_file_header [as 别名]
    def test_finalize_with_valid_checksum_type(self):

        path = os.path.join(self.metadata_file_dir, 'test.xml')
        checksum_type = 'sha1'
        context = MetadataFileContext(path, checksum_type)

        context._open_metadata_file_handle()
        context._write_file_header()
        context.finalize()

        expected_metadata_file_name = context.checksum + '-' + 'test.xml'
        expected_metadata_file_path = os.path.join(self.metadata_file_dir,
                                                   expected_metadata_file_name)
        self.assertEquals(expected_metadata_file_path, context.metadata_file_path)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:16,代码来源:test_metadata_writer.py

示例3: test_open_handle_gzip

# 需要导入模块: from pulp.plugins.util.metadata_writer import MetadataFileContext [as 别名]
# 或者: from pulp.plugins.util.metadata_writer.MetadataFileContext import _write_file_header [as 别名]
    def test_open_handle_gzip(self):

        path = os.path.join(self.metadata_file_dir, 'test.xml.gz')
        context = MetadataFileContext(path)

        context._open_metadata_file_handle()

        self.assertTrue(os.path.exists(path))

        context._write_file_header()
        context._close_metadata_file_handle()

        try:
            h = gzip.open(path)

        except Exception, e:
            self.fail(e.message)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:19,代码来源:test_metadata_writer.py

示例4: test_initialize_double_call

# 需要导入模块: from pulp.plugins.util.metadata_writer import MetadataFileContext [as 别名]
# 或者: from pulp.plugins.util.metadata_writer.MetadataFileContext import _write_file_header [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()
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:10,代码来源:test_metadata_writer.py

示例5: test_initialize

# 需要导入模块: from pulp.plugins.util.metadata_writer import MetadataFileContext [as 别名]
# 或者: from pulp.plugins.util.metadata_writer.MetadataFileContext import _write_file_header [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)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:18,代码来源:test_metadata_writer.py


注:本文中的pulp.plugins.util.metadata_writer.MetadataFileContext._write_file_header方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。