#NEWLINE# def testLoadErrors( self ) : #NEWLINE# #INDENT# test_function = self . device . _RaiseExceptionIfLoadError #NEWLINE# self . assertTrue ( ( test_function ( '' ) is None ) ) #NEWLINE# self . assertTrue ( ( test_function ( '' , expect_config_check = True ) is None ) ) #NEWLINE# self . assertTrue ( ( test_function ( '+ description "error: syntax error";' , expect_config_check = True ) is None ) ) #NEWLINE# self . assertTrue ( ( test_function ( '! description "error: syntax error";' , expect_config_check = True ) is None ) ) #NEWLINE# self . assertTrue ( ( test_function ( '[edit ... ]' ) is None ) ) #NEWLINE# self . assertTrue ( ( test_function ( '[edit ... ]\n error: foo' ) is None ) ) #NEWLINE# self . assertTrue ( ( test_function ( '[edit ... ]\n+ error: foo' ) is None ) ) #NEWLINE# missing_re_output = textwrap . dedent ( '        Entering configuration mode\n        load complete\n\n        error: Could not connect to re1 : No route to host\n        warning: Cannot connect to other RE, ignoring it\n        commit complete\n        Exiting configuration mode\n        ' ) #NEWLINE# self . assertTrue ( ( test_function ( missing_re_output , expect_commit = True ) is None ) ) #NEWLINE# warning_output = textwrap . dedent ( "      [edit]\n      Entering configuration mode\n         'interfaces'\n           warning: statement has no contents; ignored\n\n      load complete\n      commit complete\n      Exiting configuration mode\n      " ) #NEWLINE# self . assertIsNone ( test_function ( warning_output , expect_config_check = False , expect_commit = True ) ) #NEWLINE# output = textwrap . dedent ( '        Entering configuration mode\n        |load complete\n        configuration check succeedscommit complete\n        Exiting configuration mode\n        ' ) #NEWLINE# self . assertIsNone ( test_function ( warning_output , expect_config_check = True , expect_commit = True ) ) #NEWLINE# self . assertRaises ( exceptions . SetConfigSyntaxError , test_function , 'foo\n  syntax error: ' ) #NEWLINE# self . assertRaises ( exceptions . SetConfigError , test_function , '  load failed (1 errors)' ) #NEWLINE# self . assertRaises ( exceptions . SetConfigError , test_function , '  load complete (1 errors)' ) #NEWLINE# self . assertRaises ( exceptions . SetConfigError , test_function , '[edit ...]\n syntax error\nerror: foo' ) #NEWLINE# self . assertRaises ( exceptions . SetConfigError , test_function , 'error: configuration check-out failed' ) #NEWLINE# self . assertRaises ( exceptions . SetConfigSyntaxError , test_function , 'syntax error: "connect to re1 :"' ) #NEWLINE# self . assertRaises ( exceptions . SetConfigSyntaxError , test_function , 'syntax error: connect to re1 :' ) #NEWLINE# for error in self . device . JUNOS_LOAD_ERRORS : #NEWLINE# #INDENT# self . assertRaises ( exceptions . SetConfigError , test_function , error ) #NEWLINE# self . assertRaises ( exceptions . SetConfigError , test_function , error , expect_commit = True ) #NEWLINE# #UNINDENT# self . assertRaises ( exceptions . SetConfigSyntaxError , test_function , '  load failed (1 errors)' , expect_config_check = True ) #NEWLINE# self . assertRaises ( exceptions . SetConfigSyntaxError , test_function , 'error:\nsyntax error' , expect_config_check = True ) #NEWLINE# self . assertRaises ( exceptions . SetConfigError , test_function , 'configuration check succeeds\n(1 errors)' , expect_config_check = True ) #NEWLINE# self . assertRaises ( exceptions . SetConfigSyntaxError , test_function , "'configuration check succeeds'\nerror:" , expect_config_check = True ) #NEWLINE# self . assertRaises ( exceptions . SetConfigError , test_function , '+description "syntax error";\nerror:' ) #NEWLINE# syntax_error_with_missing_re = textwrap . dedent ( '\n        Entering configuration mode\n        Users currently editing the configuration:\n          netops terminal p3 (pid 44448) on since 2012-09-05 10:00:49 PDT, ...\n              [edit]\n          netops terminal p4 (pid 63408) on since 2012-09-16 23:57:00 PDT, ...\n              private [edit]\n        |\x08tmpPjACa3:1:(10) syntax error: deactivate\n        load complete (1 errors)\n\n        error: Could not connect to re1 : No route to host\n        warning: Cannot connect to other RE, ignoring it\n        commit complete\n        Exiting configuration mode\n        ' ) #NEWLINE# self . assertRaises ( exceptions . SetConfigSyntaxError , test_function , syntax_error_with_missing_re , expect_config_check = False , expect_commit = False ) #NEWLINE# self . assertRaises ( exceptions . SetConfigSyntaxError , test_function , syntax_error_with_missing_re , expect_config_check = False , expect_commit = True ) #NEWLINE# failed_commit_b_9750034 = textwrap . dedent ( '      re0:\n      error: Could not connect to re1 : No route to host\n\n      [edit]\n      ' ) #NEWLINE# self . assertRaises ( exceptions . SetConfigError , test_function , failed_commit_b_9750034 , expect_config_check = False , expect_commit = True )