<s> from oslotest import base as test_base <EOL> from ironic_python_agent import errors <EOL> DETAILS = '<STR_LIT>' <EOL> SAME_CL_DETAILS = '<STR_LIT>' <EOL> DIFF_CL_DETAILS = '<STR_LIT>' <EOL> SAME_CL_MSG = '<STR_LIT>' <EOL> SAME_DETAILS = '<STR_LIT>' <EOL> DEFAULT_DETAILS = '<STR_LIT>' <EOL> class TestError ( errors . RESTError ) : <EOL> message = '<STR_LIT:message>' <EOL> def __init__ ( self , details = None ) : <EOL> super ( TestError , self ) . __init__ ( details ) <EOL> class TestErrors ( test_base . BaseTestCase ) : <EOL> def test_RESTError ( self ) : <EOL> e = errors . RESTError ( ) <EOL> d = e . serialize ( ) <EOL> self . assertEqual ( "<STR_LIT>" , e . type ) <EOL> self . assertEqual ( errors . RESTError . status_code , e . code ) <EOL> self . assertEqual ( errors . RESTError . message , e . message ) <EOL> self . assertEqual ( errors . RESTError . details , e . details ) <EOL> self . assertEqual ( "<STR_LIT>" , d [ '<STR_LIT:type>' ] ) <EOL> self . assertEqual ( errors . RESTError . status_code , d [ '<STR_LIT:code>' ] ) <EOL> self . assertEqual ( errors . RESTError . message , d [ '<STR_LIT:message>' ] ) <EOL> self . assertEqual ( errors . RESTError . details , d [ '<STR_LIT>' ] ) <EOL> def test_RESTError_details ( self ) : <EOL> e = errors . RESTError ( DETAILS ) <EOL> self . assertEqual ( "<STR_LIT>" , e . type ) <EOL> self . assertEqual ( <NUM_LIT> , e . code ) <EOL> self . assertEqual ( errors . RESTError . message , e . message ) <EOL> self . assertEqual ( DETAILS , e . details ) <EOL> def _test_class ( self , obj , check_details ) : <EOL> """<STR_LIT>""" <EOL> obj_info = "<STR_LIT>" % obj . __dict__ <EOL> cls = obj . __class__ <EOL> d = obj . serialize ( ) <EOL> self . assertEqual ( cls . __name__ , obj . type , obj_info ) <EOL> self . assertEqual ( cls . status_code , obj . code , obj_info ) <EOL> self . assertEqual ( cls . message , obj . message , obj_info ) <EOL> self . assertEqual ( cls . __name__ , d [ '<STR_LIT:type>' ] , obj_info ) <EOL> self . assertEqual ( cls . status_code , d [ '<STR_LIT:code>' ] , obj_info ) <EOL> self . assertEqual ( cls . message , d [ '<STR_LIT:message>' ] , obj_info ) <EOL> self . assertEqual ( obj . details , d [ '<STR_LIT>' ] , obj_info ) <EOL> if check_details == SAME_CL_DETAILS : <EOL> self . assertEqual ( cls . details , obj . details , obj_info ) <EOL> elif check_details == DIFF_CL_DETAILS : <EOL> self . assertNotEqual ( cls . details , obj . details , obj_info ) <EOL> elif check_details == SAME_CL_MSG : <EOL> self . assertEqual ( cls . message , obj . details , obj_info ) <EOL> elif check_details == SAME_DETAILS : <EOL> self . assertEqual ( DETAILS , obj . details , obj_info ) <EOL> elif check_details == DEFAULT_DETAILS : <EOL> self . assertEqual ( errors . RESTError . details , obj . details , obj_info ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" % <EOL> { '<STR_LIT:info>' : obj_info , '<STR_LIT>' : check_details } ) <EOL> def test_error_classes ( self ) : <EOL> cases = [ ( errors . InvalidContentError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . NotFound ( ) , SAME_CL_DETAILS ) , <EOL> ( errors . CommandExecutionError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . InvalidCommandError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . InvalidCommandParamsError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . RequestedObjectNotFoundError ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> DIFF_CL_DETAILS ) , <EOL> ( errors . IronicAPIError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . HeartbeatError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . LookupNodeError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . LookupAgentIPError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . ImageDownloadError ( '<STR_LIT>' , DETAILS ) , <EOL> DIFF_CL_DETAILS ) , <EOL> ( errors . ImageChecksumError ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> DIFF_CL_DETAILS ) , <EOL> ( errors . ImageWriteError ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> DIFF_CL_DETAILS ) , <EOL> ( errors . ConfigDriveTooLargeError ( '<STR_LIT:filename>' , '<STR_LIT>' ) , <EOL> DIFF_CL_DETAILS ) , <EOL> ( errors . ConfigDriveWriteError ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> DIFF_CL_DETAILS ) , <EOL> ( errors . SystemRebootError ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> DIFF_CL_DETAILS ) , <EOL> ( errors . BlockDeviceEraseError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . BlockDeviceError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . VirtualMediaBootError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . UnknownNodeError ( ) , DEFAULT_DETAILS ) , <EOL> ( errors . UnknownNodeError ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . HardwareManagerNotFound ( ) , DEFAULT_DETAILS ) , <EOL> ( errors . HardwareManagerNotFound ( DETAILS ) , SAME_DETAILS ) , <EOL> ( errors . HardwareManagerMethodNotFound ( '<STR_LIT>' ) , <EOL> DIFF_CL_DETAILS ) , <EOL> ( errors . IncompatibleHardwareMethodError ( ) , DEFAULT_DETAILS ) , <EOL> ( errors . IncompatibleHardwareMethodError ( DETAILS ) , <EOL> SAME_DETAILS ) , <EOL> ] <EOL> for ( obj , check_details ) in cases : <EOL> self . _test_class ( obj , check_details ) <EOL> def test_error_string ( self ) : <EOL> err = TestError ( '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , str ( err ) ) <EOL> self . assertEqual ( '<STR_LIT>' , repr ( err ) ) </s>
