def test_raises_error_when_omshell_crashes(self):
error_message = factory.make_name("error").encode("ascii")
omshell = Mock()
omshell.create.side_effect = ExternalProcessError(
returncode=2, cmd=("omshell",), output=error_message)
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: ..." % (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: ..." % (mac, ip),
logger.output)
评论列表
文章目录