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.remove.side_effect = error
mac = factory.make_mac_address()
with FakeLogger("maas.dhcp") as logger:
error = self.assertRaises(
exceptions.CannotRemoveHostMap, dhcp._remove_host_map,
omshell, mac)
# The CannotCreateHostMap exception includes a message describing the
# problematic mapping.
self.assertDocTestMatches(
"Could not remove host map for %s: "
"The DHCP server could not be reached." % (mac),
str(error))
# A message is also written to the maas.dhcp logger that describes the
# problematic mapping.
self.assertDocTestMatches(
"Could not remove host map for %s: "
"The DHCP server could not be reached." % (mac),
logger.output)
评论列表
文章目录