本文整理汇总了Python中bundlewrap.operations.RunResult.return_code方法的典型用法代码示例。如果您正苦于以下问题:Python RunResult.return_code方法的具体用法?Python RunResult.return_code怎么用?Python RunResult.return_code使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bundlewrap.operations.RunResult
的用法示例。
在下文中一共展示了RunResult.return_code方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_groups
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_groups(self, _groups_for_user):
_groups_for_user.return_value = ["group1", "group3"]
bundle = MagicMock()
user = users.User(
bundle,
"bundlewrap",
{
'full_name': "Blöck Wart",
'gid': 2345,
'groups': ["group1", "group2"],
'home': "/home/bundlewrap",
'password_hash': "secret",
'shell': "/bin/bash",
'uid': 1123,
},
)
passwd_grep_result = RunResult()
passwd_grep_result.return_code = 0
passwd_grep_result.stdout = "bundlewrap:x:1123:2345:Blöck Wart:/home/bundlewrap:/bin/bash\n"
shadow_grep_result = RunResult()
shadow_grep_result.return_code = 0
shadow_grep_result.stdout = "bundlewrap:secret:::::::"
results = [shadow_grep_result, passwd_grep_result]
def pop_result(*args, **kwargs):
return results.pop()
bundle.node.run.side_effect = pop_result
status = user.get_status()
self.assertFalse(status.correct)
示例2: test_installed
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_installed(self):
runresult = RunResult()
runresult.return_code = 0
runresult.stdout = "Status: install ok installed\n"
node = MagicMock()
node.run.return_value = runresult
self.assertTrue(pkg_apt.pkg_installed(node, "foo"))
示例3: test_running
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_running(self):
runresult = RunResult()
runresult.return_code = 0
runresult.stdout = "foo start/running, process 1234\n"
node = MagicMock()
node.run.return_value = runresult
self.assertTrue(svc_upstart.svc_running(node, "foo"))
示例4: test_installed
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_installed(self):
runresult = RunResult()
runresult.return_code = 0
runresult.stdout = "foo 1.0.0-1\n"
node = MagicMock()
node.run.return_value = runresult
self.assertTrue(pkg_pacman.pkg_installed(node, "foo"))
示例5: test_not_installed
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_not_installed(self):
runresult = RunResult()
runresult.return_code = 1
runresult.stdout = "error: package 'foo' was not found"
node = MagicMock()
node.run.return_value = runresult
self.assertFalse(pkg_pacman.pkg_installed(node, "foo"))
示例6: test_not_installed
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_not_installed(self):
runresult = RunResult()
runresult.return_code = 1
runresult.stdout = "Error: No matching Packages to list\n"
node = MagicMock()
node.run.return_value = runresult
self.assertFalse(pkg_yum.pkg_installed(node, "foo"))
示例7: test_not_running
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_not_running(self):
runresult = RunResult()
runresult.return_code = 3
runresult.stdout = "whatever, does not matter"
node = MagicMock()
node.run.return_value = runresult
self.assertFalse(svc_systemd.svc_running(node, "foo"))
示例8: test_locked
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_locked(self, ask_interactively):
node = MagicMock()
runres = RunResult()
runres.return_code = 1
node.run.return_value = runres
with self.assertRaises(NodeAlreadyLockedException):
with NodeLock(node, False, ignore=False):
pass
示例9: test_not_installed
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_not_installed(self):
runresult = RunResult()
runresult.return_code = 1
runresult.stdout = (
"Package `foo' is not installed and no info is available.\n"
"Use dpkg --info (= dpkg-deb --info) to examine archive files,\n"
"and dpkg --contents (= dpkg-deb --contents) to list their contents.\n"
)
node = MagicMock()
node.run.return_value = runresult
self.assertFalse(pkg_apt.pkg_installed(node, "foo"))
示例10: test_group_fail
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_group_fail(self):
bundle = MagicMock()
group = groups.Group(
bundle,
"bundlewrap",
{ 'gid': 2345 },
)
grep_result = RunResult()
grep_result.return_code = 1
bundle.node.run.return_value = grep_result
status = group.get_status()
self.assertFalse(status.correct)
self.assertFalse(status.info['exists'])
示例11: test_gid
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_gid(self):
bundle = MagicMock()
group = groups.Group(
bundle,
"bundlewrap",
{ 'gid': 2345 },
)
grep_result = RunResult()
grep_result.return_code = 0
grep_result.stdout = "bundlewrap:x:5432:user1,user2\n"
bundle.node.run.return_value = grep_result
status = group.get_status()
self.assertFalse(status.correct)
示例12: test_delete
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_delete(self):
bundle = MagicMock()
user = users.User(
bundle,
"bundlewrap",
{'delete': True},
)
passwd_grep_result = RunResult()
passwd_grep_result.return_code = 0
passwd_grep_result.stdout = "bundlewrap:x:1123:2345:Blöck Wart:/home/bundlewrap:/bin/bash\n"
bundle.node.run.return_value = passwd_grep_result
status = user.get_status()
self.assertFalse(status.correct)
self.assertTrue(status.info['exists'])
示例13: test_passwd_fail
# 需要导入模块: from bundlewrap.operations import RunResult [as 别名]
# 或者: from bundlewrap.operations.RunResult import return_code [as 别名]
def test_passwd_fail(self):
bundle = MagicMock()
user = users.User(
bundle,
"bundlewrap",
{
'full_name': "Blöck Wart",
'gid': 2345,
'groups': ["group1", "group2"],
'home': "/home/bundlewrap",
'password_hash': "secret",
'shell': "/bin/bash",
'uid': 1123,
},
)
passwd_grep_result = RunResult()
passwd_grep_result.return_code = 1
bundle.node.run.return_value = passwd_grep_result
status = user.get_status()
self.assertFalse(status.correct)
self.assertFalse(status.info['exists'])