def test_compose_errors_if_not_default_or_maas_profile(self): pod_id = factory.make_name("pod_id") driver = lxd_module.LXDPodDriver() Client = self.patch(driver, "get_client") client = Client.return_value client.profiles.get.side_effect = [ lxd_module.NotFound("Error"), lxd_module.NotFound("Error"), ] error_msg = (f"Pod {pod_id}: MAAS needs LXD to have either a 'maas' " "profile or a 'default' profile, defined.") with ExpectedException(lxd_module.LXDPodError, error_msg): yield driver.compose(pod_id, {}, None)
def test_get_machine_raises_error_when_machine_not_found(self): context = self.make_parameters_context() pod_id = factory.make_name("pod_id") instance_name = context.get("instance_name") driver = lxd_module.LXDPodDriver() Client = self.patch(driver, "get_client") client = Client.return_value client.virtual_machines.get.side_effect = lxd_module.NotFound("Error") error_msg = f"Pod {pod_id}: LXD VM {instance_name} not found." with ExpectedException(lxd_module.LXDPodError, error_msg): yield driver.get_machine(pod_id, context)