test_dhcp.py 文件源码

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

项目:maas 作者: maas 项目源码 文件源码
def test_raises_error_when_omshell_not_connected(self):
        error = ExternalProcessError(
            returncode=2, cmd=("omshell",), output="")
        self.patch(ExternalProcessError, 'output_as_unicode', 'not connected.')
        omshell = Mock()
        omshell.create.side_effect = error
        mac = factory.make_mac_address()
        ip = factory.make_ip_address()
        with FakeLogger("maas.dhcp") as logger:
            error = self.assertRaises(
                exceptions.CannotCreateHostMap, dhcp._create_host_map,
                omshell, mac, ip)
        # The CannotCreateHostMap exception includes a message describing the
        # problematic mapping.
        self.assertDocTestMatches(
            "Could not create host map for %s -> %s: "
            "The DHCP server could not be reached." % (mac, ip),
            str(error))
        # A message is also written to the maas.dhcp logger that describes the
        # problematic mapping.
        self.assertDocTestMatches(
            "Could not create host map for %s -> %s: "
            "The DHCP server could not be reached." % (mac, ip),
            logger.output)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号