<s> """<STR_LIT>""" <EOL> from cStringIO import StringIO <EOL> from samba . netcmd import Command <EOL> from samba . netcmd . testparm import cmd_testparm <EOL> from samba . netcmd . main import cmd_sambatool <EOL> import samba . tests <EOL> class NetCmdTestCase ( samba . tests . TestCase ) : <EOL> def run_netcmd ( self , cmd_klass , args , retcode = <NUM_LIT:0> ) : <EOL> cmd = cmd_klass ( outf = StringIO ( ) , errf = StringIO ( ) ) <EOL> try : <EOL> retval = cmd . _run ( cmd_klass . __name__ , * args ) <EOL> except Exception , e : <EOL> cmd . show_command_error ( e ) <EOL> retval = <NUM_LIT:1> <EOL> self . assertEquals ( retcode , retval ) <EOL> return cmd . outf . getvalue ( ) , cmd . errf . getvalue ( ) <EOL> def iter_all_subcommands ( self ) : <EOL> todo = [ ] <EOL> todo . extend ( cmd_sambatool . subcommands . items ( ) ) <EOL> while todo : <EOL> ( path , cmd ) = todo . pop ( ) <EOL> yield path , cmd <EOL> subcmds = getattr ( cmd , "<STR_LIT>" , { } ) <EOL> todo . extend ( [ ( path + "<STR_LIT:U+0020>" + k , v ) for ( k , v ) in <EOL> subcmds . iteritems ( ) ] ) <EOL> class TestParmTests ( NetCmdTestCase ) : <EOL> def test_no_client_ip ( self ) : <EOL> out , err = self . run_netcmd ( cmd_testparm , [ "<STR_LIT>" ] , <EOL> retcode = - <NUM_LIT:1> ) <EOL> self . assertEquals ( "<STR_LIT>" , out ) <EOL> self . assertEquals ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , err ) <EOL> class CommandTests ( NetCmdTestCase ) : <EOL> def test_description ( self ) : <EOL> class cmd_foo ( Command ) : <EOL> """<STR_LIT>""" <EOL> self . assertEquals ( "<STR_LIT>" , cmd_foo ( ) . short_description ) <EOL> def test_name ( self ) : <EOL> class cmd_foo ( Command ) : <EOL> pass <EOL> self . assertEquals ( "<STR_LIT:foo>" , cmd_foo ( ) . name ) <EOL> def test_synopsis_everywhere ( self ) : <EOL> missing = [ ] <EOL> for path , cmd in self . iter_all_subcommands ( ) : <EOL> if cmd . synopsis is None : <EOL> missing . append ( path ) <EOL> if missing : <EOL> self . fail ( "<STR_LIT>" % <EOL> missing ) <EOL> def test_short_description_everywhere ( self ) : <EOL> missing = [ ] <EOL> for path , cmd in self . iter_all_subcommands ( ) : <EOL> if cmd . short_description is None : <EOL> missing . append ( path ) <EOL> if not missing : <EOL> return <EOL> self . fail ( <EOL> "<STR_LIT>" % <EOL> missing ) </s>
