def test_get_client_raises_error_when_cannot_connect(self):
     context = self.make_parameters_context()
     pod_id = factory.make_name("pod_id")
     Client = self.patch(lxd_module, "Client")
     Client.side_effect = lxd_module.ClientConnectionFailed()
     driver = lxd_module.LXDPodDriver()
     error_msg = f"Pod {pod_id}: Failed to connect to the LXD REST API."
     with ExpectedException(lxd_module.LXDPodError, error_msg):
         yield driver.get_client(pod_id, context)
Exemple #2
0
 def test_get_client_raises_error_when_cannot_connect(self):
     context = self.make_parameters_context()
     pod_id = factory.make_name("pod_id")
     Client = self.patch(lxd_module, "Client")
     Client.side_effect = lxd_module.ClientConnectionFailed()
     # Getting the cert tuple can cause a certificate to be generated which
     # can be slow but isn't needed for this test.
     self.patch(maas_certificates, "get_maas_cert_tuple")
     driver = lxd_module.LXDPodDriver()
     error_msg = f"Pod {pod_id}: Failed to connect to the LXD REST API."
     with ExpectedException(lxd_module.LXDPodError, error_msg):
         yield driver.get_client(pod_id, context)