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


Python MagicMock.node方法代码示例

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


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

示例1: test_chmod

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import node [as 别名]
 def test_chmod(self):
     node = MagicMock()
     bundle = MagicMock()
     bundle.node = node
     f = directories.Directory(bundle, "/foo", {"mode": "1234"})
     f._fix_mode(MagicMock())
     node.run.assert_called_once_with("chmod 1234 -- /foo")
开发者ID:lowks,项目名称:bundlewrap,代码行数:9,代码来源:directories_tests.py

示例2: test_create

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import node [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)
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:31,代码来源:files_tests.py

示例3: test_rm

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import node [as 别名]
 def test_rm(self, fix_mode, fix_owner):
     node = MagicMock()
     bundle = MagicMock()
     bundle.node = node
     f = directories.Directory(bundle, "/foo", {})
     f._fix_type(MagicMock())
     assert call("rm -rf -- /foo") in node.run.call_args_list
     assert call("mkdir -p -- /foo") in node.run.call_args_list
     fix_mode.assert_called_once()
     fix_owner.assert_called_once()
开发者ID:lowks,项目名称:bundlewrap,代码行数:12,代码来源:directories_tests.py

示例4: test_chmod

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import node [as 别名]
 def test_chmod(self):
     node = MagicMock()
     bundle = MagicMock()
     bundle.node = node
     f = files.File(
         bundle,
         "/foo",
         {'owner': "jcleese", 'group': "mp"},
     )
     f._fix_owner(MagicMock())
     node.run.assert_called_once_with("chown jcleese:mp -- /foo")
开发者ID:jrragan,项目名称:bundlewrap,代码行数:13,代码来源:files_tests.py

示例5: test_chmod

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import node [as 别名]
 def test_chmod(self):
     node = MagicMock()
     bundle = MagicMock()
     bundle.node = node
     f = symlinks.Symlink(
         bundle,
         "/foo",
         {'owner': "jcleese", 'group': "mp", 'target': "/bar"},
     )
     f._fix_owner(MagicMock())
     node.run.assert_called_once_with("chown -h jcleese:mp -- /foo")
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:13,代码来源:symlinks_tests.py

示例6: test_rm

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import node [as 别名]
 def test_rm(self, fix_content):
     node = MagicMock()
     bundle = MagicMock()
     bundle.node = node
     f = files.File(
         bundle,
         "/foo",
         {},
     )
     f._fix_type(MagicMock())
     assert call("rm -rf -- /foo") in node.run.call_args_list
     assert call("mkdir -p -- /") in node.run.call_args_list
     assert fix_content.call_count == 1
开发者ID:jrragan,项目名称:bundlewrap,代码行数:15,代码来源:files_tests.py

示例7: test_regular

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import node [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
开发者ID:jrragan,项目名称:bundlewrap,代码行数:15,代码来源:files_tests.py

示例8: test_rm

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import node [as 别名]
 def test_rm(self, fix_owner):
     node = MagicMock()
     bundle = MagicMock()
     bundle.node = node
     f = symlinks.Symlink(
         bundle,
         "/foo",
         {'target': "/bar"},
     )
     f._fix_type(MagicMock())
     assert call("rm -rf -- /foo") in node.run.call_args_list
     assert call("ln -s -- /bar /foo") in node.run.call_args_list
     fix_owner.assert_called_once()
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:15,代码来源:symlinks_tests.py

示例9: test_rm

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import node [as 别名]
 def test_rm(self, fix_owner):
     node = MagicMock()
     bundle = MagicMock()
     bundle.node = node
     f = symlinks.Symlink(
         bundle,
         "/foo",
         {
             'owner': "bw",
             'target': "/bar",
         },
     )
     f._fix_type(MagicMock())
     assert call("rm -rf -- /foo") in node.run.call_args_list
     assert call("ln -s -- /bar /foo") in node.run.call_args_list
     assert fix_owner.call_count == 1
开发者ID:jrragan,项目名称:bundlewrap,代码行数:18,代码来源:symlinks_tests.py

示例10: test_rm

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import node [as 别名]
 def test_rm(self, fix_mode, fix_owner):
     node = MagicMock()
     bundle = MagicMock()
     bundle.node = node
     f = directories.Directory(
         bundle,
         "/foo",
         {
             'mode': "0755",
             'owner': "bw",
         },
     )
     f._fix_type(MagicMock())
     assert call("rm -rf -- /foo") in node.run.call_args_list
     assert call("mkdir -p -- /foo") in node.run.call_args_list
     assert fix_mode.call_count == 1
     assert fix_owner.call_count == 1
开发者ID:jrragan,项目名称:bundlewrap,代码行数:19,代码来源:directories_tests.py

示例11: test_binary

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import node [as 别名]
 def test_binary(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_type': 'binary', 'source': 'foobar'},
     )
     f._fix_content(MagicMock())
     node.upload.assert_called_once_with(
         "/b/dir/files/foobar",
         "/foo",
         owner="",
         group="",
         mode=None,
     )
开发者ID:jrragan,项目名称:bundlewrap,代码行数:21,代码来源:files_tests.py


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