本文整理汇总了Python中unittest.mock.MagicMock.bundle_dir方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.bundle_dir方法的具体用法?Python MagicMock.bundle_dir怎么用?Python MagicMock.bundle_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.bundle_dir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_content_fails
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import bundle_dir [as 别名]
def test_content_fails(self):
bundle = MagicMock()
bundle.bundle_dir = "/tmp/bw_file_test"
bundle.bundle_data_dir = "/d/dir"
f = files.File(bundle, "foo", { 'content_type': 'mako', 'source': "fail" })
with self.assertRaises(CompileException):
f.test()
示例2: test_missing_template
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import bundle_dir [as 别名]
def test_missing_template(self):
bundle = MagicMock()
bundle.bundle_dir = "/bogus"
bundle.bundle_data_dir = "/notthere"
f = files.File(bundle, "foo", { 'source': "bogus" })
with self.assertRaises(BundleError):
f.test()
示例3: test_create
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import bundle_dir [as 别名]
def test_create(self):
if system() == "Darwin":
return
handle, target_file = mkstemp()
remove(target_file)
bundle = MagicMock()
bundle.bundle_dir = mkdtemp()
bundle.bundle_data_dir = mkdtemp()
bundle.node = Node('localhost')
Repository().add_node(bundle.node)
item = files.File(
bundle,
target_file,
{
'content_type': 'mako',
'owner': getuser(),
'source': 'my_template',
},
)
mkdir(item.item_dir)
with open(join(item.item_dir, "my_template"), 'w') as f:
f.write("Hi from ${node.name}!")
item.apply(interactive=False)
with open(target_file) as f:
content = f.read()
try:
self.assertEqual(content, "Hi from localhost!")
finally:
remove(target_file)
示例4: test_binary
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import bundle_dir [as 别名]
def test_binary(self, hash_local_file):
bundle = MagicMock()
bundle.bundle_dir = "/b/dir"
bundle.bundle_data_dir = "/d/dir"
f = files.File(
bundle,
"/foo",
{'content_type': 'binary', 'source': 'foobar'},
)
self.assertEqual(f.content_hash, "47")
hash_local_file.assert_called_once_with("/b/dir/files/foobar")
示例5: test_regular
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import bundle_dir [as 别名]
def test_regular(self):
node = MagicMock()
bundle = MagicMock()
bundle.bundle_dir = "/b/dir"
bundle.bundle_data_dir = "/d/dir"
bundle.node = node
f = files.File(
bundle,
"/foo",
{'content': "47", 'content_type': 'mako'},
)
f._fix_content(MagicMock())
assert node.upload.call_count == 1
示例6: test_content_ok
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import bundle_dir [as 别名]
def test_content_ok(self):
bundle = MagicMock()
bundle.bundle_dir = "/tmp/bw_file_test"
bundle.bundle_data_dir = "/d/dir"
f = files.File(bundle, "foo", { 'content_type': 'mako', 'source': "success" })
f.test()