本文整理汇总了Python中pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory._add_module方法的典型用法代码示例。如果您正苦于以下问题:Python SynchronizeWithDirectory._add_module方法的具体用法?Python SynchronizeWithDirectory._add_module怎么用?Python SynchronizeWithDirectory._add_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory
的用法示例。
在下文中一共展示了SynchronizeWithDirectory._add_module方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_module_not_copied
# 需要导入模块: from pulp_puppet.plugins.importers.directory import SynchronizeWithDirectory [as 别名]
# 或者: from pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory import _add_module [as 别名]
def test_add_module_not_copied(self, mock_shutil):
module_path = '/tmp/mod.tar.gz'
feed_url = 'http://host/root/PULP_MANAFEST'
unit_key = {'name': 'puppet-module'}
unit_metadata = {'A': 1, 'B': 2}
unit = Mock()
unit.storage_path = os.path.join(os.getcwd(), __file__)
mock_conduit = Mock()
mock_conduit.init_unit = Mock(return_value=unit)
config = {constants.CONFIG_FEED: feed_url}
mock_module = Mock()
mock_module.unit_key = Mock(return_value=unit_key)
mock_module.unit_metadata = Mock(return_value=unit_metadata)
mock_module.filename = Mock(return_value='puppet-module')
# test
method = SynchronizeWithDirectory(mock_conduit, config)
method._add_module(module_path, mock_module)
# validation
self.assertFalse(mock_shutil.copy.called)
示例2: test_add_module
# 需要导入模块: from pulp_puppet.plugins.importers.directory import SynchronizeWithDirectory [as 别名]
# 或者: from pulp_puppet.plugins.importers.directory.SynchronizeWithDirectory import _add_module [as 别名]
def test_add_module(self, mock_shutil):
module_path = '/tmp/mod.tar.gz'
feed_url = 'http://host/root/PULP_MANAFEST'
unit_key = {'name': 'puppet-module'}
unit_metadata = {'A': 1, 'B': 2}
unit = Mock()
unit.storage_path = '/tmp/%s' % uuid4()
mock_conduit = Mock()
mock_conduit.init_unit = Mock(return_value=unit)
config = {constants.CONFIG_FEED: feed_url}
mock_module = Mock()
mock_module.unit_key = Mock(return_value=unit_key)
mock_module.unit_metadata = Mock(return_value=unit_metadata)
mock_module.filename = Mock(return_value='puppet-module')
# test
method = SynchronizeWithDirectory(mock_conduit, config)
method._add_module(module_path, mock_module)
# validation
mock_conduit.init_unit.assert_called_with(
constants.TYPE_PUPPET_MODULE, unit_key, unit_metadata, mock_module.filename())
mock_shutil.copy.assert_called_with(module_path, unit.storage_path)