test_changer.py 文件源码

python
阅读 15 收藏 0 点赞 0 评论 0

项目:landscape-client 作者: CanonicalLtd 项目源码 文件源码
def test_change_packages_with_failed_reboot(self):
        """
        When a C{reboot-if-necessary} flag is passed in the C{change-packages},
        A C{ShutdownProtocol} is created and the package result change is
        returned, even if the reboot fails.
        """
        self.store.add_task("changer",
                            {"type": "change-packages", "install": [2],
                             "binaries": [(HASH2, 2, PKGDEB2)],
                             "operation-id": 123,
                             "reboot-if-necessary": True})

        def return_good_result(self):
            return "Yeah, I did whatever you've asked for!"
        self.replace_perform_changes(return_good_result)

        result = self.changer.handle_tasks()

        def got_result(result):
            self.assertMessages(self.get_pending_messages(),
                                [{"operation-id": 123,
                                  "result-code": 1,
                                  "result-text": "Yeah, I did whatever you've "
                                                 "asked for!",
                                  "type": "change-packages-result"}])
            self.log_helper.ignore_errors(ShutdownFailedError)

        self.landscape_reactor.advance(5)
        [arguments] = self.process_factory.spawns
        protocol = arguments[0]
        protocol.processEnded(Failure(ProcessTerminated(exitCode=1)))
        self.landscape_reactor.advance(10)
        return result.addCallback(got_result)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号