<s> """<STR_LIT>""" <EOL> import logging <EOL> import SoftLayer <EOL> from SoftLayer . CLI import core <EOL> from SoftLayer . CLI import environment <EOL> from SoftLayer import testing <EOL> from SoftLayer import utils <EOL> import click <EOL> import mock <EOL> class CoreTests ( testing . TestCase ) : <EOL> def test_load_all ( self ) : <EOL> for path , cmd in recursive_subcommand_loader ( core . cli , <EOL> current_path = '<STR_LIT:root>' ) : <EOL> try : <EOL> cmd . main ( args = [ '<STR_LIT>' ] ) <EOL> except SystemExit as ex : <EOL> if ex . code != <NUM_LIT:0> : <EOL> self . fail ( "<STR_LIT>" % path ) <EOL> def test_verbose_max ( self ) : <EOL> with mock . patch ( '<STR_LIT>' ) as log_mock : <EOL> result = self . run_command ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' ] ) <EOL> self . assertEqual ( result . exit_code , <NUM_LIT:0> ) <EOL> log_mock ( ) . addHandler . assert_called_with ( mock . ANY ) <EOL> log_mock ( ) . setLevel . assert_called_with ( logging . DEBUG ) <EOL> def test_build_client ( self ) : <EOL> env = environment . Environment ( ) <EOL> result = self . run_command ( [ '<STR_LIT>' , '<STR_LIT:list>' ] , env = env ) <EOL> self . assertEqual ( result . exit_code , <NUM_LIT:0> ) <EOL> self . assertIsNotNone ( env . client ) <EOL> def test_diagnostics ( self ) : <EOL> result = self . run_command ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:list>' ] ) <EOL> self . assertEqual ( result . exit_code , <NUM_LIT:0> ) <EOL> self . assertIn ( '<STR_LIT>' , result . output ) <EOL> self . assertIn ( '<STR_LIT>' , result . output ) <EOL> self . assertIn ( '<STR_LIT>' , result . output ) <EOL> self . assertIn ( '<STR_LIT>' , result . output ) <EOL> self . assertIn ( '<STR_LIT>' , result . output ) <EOL> self . assertIn ( '<STR_LIT>' , result . output ) <EOL> class CoreMainTests ( testing . TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' , new_callable = utils . StringIO ) <EOL> def test_unexpected_error ( self , stdoutmock , climock ) : <EOL> climock . side_effect = AttributeError ( '<STR_LIT>' ) <EOL> self . assertRaises ( SystemExit , core . main ) <EOL> self . assertIn ( "<STR_LIT>" , <EOL> stdoutmock . getvalue ( ) ) <EOL> self . assertIn ( "<STR_LIT>" , <EOL> stdoutmock . getvalue ( ) ) <EOL> self . assertIn ( "<STR_LIT>" , <EOL> stdoutmock . getvalue ( ) ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' , new_callable = utils . StringIO ) <EOL> def test_sl_error ( self , stdoutmock , climock ) : <EOL> ex = SoftLayer . SoftLayerAPIError ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> climock . side_effect = ex <EOL> self . assertRaises ( SystemExit , core . main ) <EOL> self . assertIn ( "<STR_LIT>" , <EOL> stdoutmock . getvalue ( ) ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' , new_callable = utils . StringIO ) <EOL> def test_auth_error ( self , stdoutmock , climock ) : <EOL> ex = SoftLayer . SoftLayerAPIError ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> climock . side_effect = ex <EOL> self . assertRaises ( SystemExit , core . main ) <EOL> self . assertIn ( "<STR_LIT>" , stdoutmock . getvalue ( ) ) <EOL> self . assertIn ( "<STR_LIT>" , stdoutmock . getvalue ( ) ) <EOL> def recursive_subcommand_loader ( root , current_path = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> if getattr ( root , '<STR_LIT>' , None ) is None : <EOL> return <EOL> ctx = click . Context ( root ) <EOL> for command in root . list_commands ( ctx ) : <EOL> new_path = '<STR_LIT>' % ( current_path , command ) <EOL> logging . info ( "<STR_LIT>" , new_path ) <EOL> new_root = root . get_command ( ctx , command ) <EOL> if new_root is None : <EOL> raise Exception ( '<STR_LIT>' % command ) <EOL> for path , cmd in recursive_subcommand_loader ( new_root , <EOL> current_path = new_path ) : <EOL> yield path , cmd <EOL> yield current_path , new_root </s>
