當前位置: 首頁>>代碼示例>>Python>>正文


Python RunResult.return_code方法代碼示例

本文整理匯總了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)
開發者ID:bkendinibilir,項目名稱:bundlewrap,代碼行數:34,代碼來源:users_tests.py

示例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"))
開發者ID:bkendinibilir,項目名稱:bundlewrap,代碼行數:9,代碼來源:pkg_apt_tests.py

示例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"))
開發者ID:bkendinibilir,項目名稱:bundlewrap,代碼行數:9,代碼來源:svc_upstart_tests.py

示例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"))
開發者ID:bkendinibilir,項目名稱:bundlewrap,代碼行數:9,代碼來源:pkg_pacman_tests.py

示例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"))
開發者ID:bkendinibilir,項目名稱:bundlewrap,代碼行數:9,代碼來源:pkg_pacman_tests.py

示例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"))
開發者ID:bkendinibilir,項目名稱:bundlewrap,代碼行數:9,代碼來源:pkg_yum_tests.py

示例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"))
開發者ID:bkendinibilir,項目名稱:bundlewrap,代碼行數:9,代碼來源:svc_systemd_tests.py

示例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
開發者ID:mfriedenhagen,項目名稱:bundlewrap,代碼行數:10,代碼來源:node_tests.py

示例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"))
開發者ID:bkendinibilir,項目名稱:bundlewrap,代碼行數:13,代碼來源:pkg_apt_tests.py

示例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'])
開發者ID:mfriedenhagen,項目名稱:bundlewrap,代碼行數:18,代碼來源:groups_tests.py

示例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)
開發者ID:mfriedenhagen,項目名稱:bundlewrap,代碼行數:18,代碼來源:groups_tests.py

示例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'])
開發者ID:bkendinibilir,項目名稱:bundlewrap,代碼行數:19,代碼來源:users_tests.py

示例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'])
開發者ID:bkendinibilir,項目名稱:bundlewrap,代碼行數:26,代碼來源:users_tests.py


注:本文中的bundlewrap.operations.RunResult.return_code方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。