def test_malformed_response(self): def raises(): raise libcloud.compute.types.MalformedResponseError( "Failed to parse XML", body="A bad response", driver=object() ) assert config.handle_errors(raises, out=self.devnull) == config.MALFORMED_RESPONSE
def test_service_unavailable(self): def raises(): raise libcloud.compute.types.MalformedResponseError( "Failed to parse XML", body="Service Unavailable", driver=object() ) assert config.handle_errors(raises, out=self.devnull) == config.SERVICE_UNAVAILABLE
def test_deployment_error(self): def raises(): try: None.foo except AttributeError as e: raise libcloud.compute.types.DeploymentError(object(), e) assert config.handle_errors(raises, out=self.devnull) == config.DEPLOYMENT_ERROR
def test_timeout(self): def raises(): try: None.open_sftp_client except AttributeError as e: raise libcloud.compute.types.DeploymentError(object(), e) assert config.handle_errors(raises, out=self.devnull) == config.TIMEOUT
def main(): parsed = config.reconfig(parser) if parsed.verbose: print('parsed: {0}'.format(parsed)) if parsed.testresults: try: dom = xml.dom.minidom.parse(parsed.testresults) except: print('ERROR: could not parse {0.testresults}, aborting destroy'.format(parsed), file=sys.stderr) return 2 suite = dom.getElementsByTagName('testsuite')[0] if int(suite.getAttribute('errors')) != 0 or int(suite.getAttribute('failures')) != 0: print('ERROR: not all tests passed, aborting destroy', file=sys.stderr) return 3 return config.handle_errors(destroy, parsed)
def test_generic_exception(self): def raises(): raise Exception() assert config.handle_errors(raises, out=self.devnull) == config.EXCEPTION
def test_simple_fail(self): assert config.handle_errors(lambda: 1) == 1
def test_parsed_success(self): assert config.handle_errors(lambda parsed: 0, object()) == 0
def test_simple_success(self): assert config.handle_errors(lambda: 0) == 0
def main(): return config.handle_errors(deploy_retcode)
def main(): return config.handle_errors(print_list)