def test__converts_stop_dhcp_server_failure_to_CannotConfigureDHCP(self): self.patch_sudo_write_file() self.patch_sudo_delete_file() self.patch_ensureService().side_effect = ServiceActionError() with ExpectedException(exceptions.CannotConfigureDHCP): yield self.configure( factory.make_name('key'), [], [], [], [], [])
def test__does_not_log_ServiceActionError(self): self.patch_sudo_write_file() self.patch_sudo_delete_file() self.patch_ensureService().side_effect = ServiceActionError() with FakeLogger("maas") as logger: with ExpectedException(exceptions.CannotConfigureDHCP): yield self.configure(factory.make_name("key"), [], [], [], [], []) self.assertDocTestMatches("", logger.output)
def test__converts_dhcp_restart_failure_to_CannotConfigureDHCP(self): self.patch_sudo_write_file() self.patch_sudo_delete_file() self.patch_restartService().side_effect = ServiceActionError() failover_peers = [make_failover_peer_config()] shared_networks = fix_shared_networks_failover( [make_shared_network()], failover_peers) with ExpectedException(exceptions.CannotConfigureDHCP): yield self.configure( factory.make_name('key'), failover_peers, shared_networks, [make_host()], [make_interface()], make_global_dhcp_snippets())
def test__does_not_log_ServiceActionError_when_restarting(self): self.patch_sudo_write_file() self.patch_restartService().side_effect = ServiceActionError() failover_peers = [make_failover_peer_config()] shared_networks = fix_shared_networks_failover([make_shared_network()], failover_peers) with FakeLogger("maas") as logger: with ExpectedException(exceptions.CannotConfigureDHCP): yield self.configure(factory.make_name('key'), failover_peers, shared_networks, [make_host()], [make_interface()], make_global_dhcp_snippets()) self.assertDocTestMatches("", logger.output)