def test_unsupported_guest(self): class UnsupportedGuestService(encryptor_service.BaseEncryptorService): def __init__(self): super(UnsupportedGuestService, self).__init__("localhost", 80) def is_encryptor_up(self): return True def get_status(self): return { "state": encryptor_service.ENCRYPT_FAILED, "failure_code": encryptor_service.FAILURE_CODE_UNSUPPORTED_GUEST, "percent_complete": 0, } with self.assertRaises(encrypt_ami.UnsupportedGuestError): encrypt_ami._wait_for_encryption(UnsupportedGuestService())
def test_encryption_fails(self): svc = FailedEncryptionService("192.168.1.1") with self.assertRaisesRegexp(encrypt_ami.EncryptionError, "Encryption failed"): encrypt_ami._wait_for_encryption(svc)