<s> from rally . common . plugin import discover <EOL> from rally . common . plugin import info <EOL> from rally . deployment import engine <EOL> from rally . deployment . serverprovider import provider <EOL> from rally . task import scenario <EOL> from rally . task import sla <EOL> from tests . unit import test <EOL> class DocstringsTestCase ( test . TestCase ) : <EOL> def _assert_class_has_docstrings ( self , obj , long_description = True ) : <EOL> if not obj . __module__ . startswith ( "<STR_LIT>" ) : <EOL> return <EOL> self . assertIsNotNone ( obj . __doc__ , <EOL> "<STR_LIT>" % <EOL> obj ) <EOL> doc = info . parse_docstring ( obj . __doc__ ) <EOL> self . assertIsNotNone ( <EOL> doc [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" % obj ) <EOL> if long_description : <EOL> self . assertIsNotNone ( <EOL> doc [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" % obj ) <EOL> def test_all_scenarios_have_docstrings ( self ) : <EOL> ignored_params = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> for scenario_inst in scenario . Scenario . get_all ( ) : <EOL> self . assertIsNotNone ( scenario_inst . __doc__ , <EOL> "<STR_LIT>" % <EOL> scenario_inst . get_name ( ) ) <EOL> doc = info . parse_docstring ( scenario_inst . __doc__ ) <EOL> short_description = doc [ "<STR_LIT>" ] <EOL> self . assertIsNotNone ( short_description , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> scenario_inst . get_name ( ) ) <EOL> self . assertFalse ( short_description . startswith ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % scenario_inst . get_name ( ) ) <EOL> params_count = scenario_inst . __code__ . co_argcount <EOL> params = scenario_inst . __code__ . co_varnames [ : params_count ] <EOL> documented_params = [ p [ "<STR_LIT:name>" ] for p in doc [ "<STR_LIT>" ] ] <EOL> for param in params : <EOL> if param not in ignored_params : <EOL> self . assertIn ( param , documented_params , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> { "<STR_LIT>" : scenario_inst . get_name ( ) , <EOL> "<STR_LIT>" : param } ) <EOL> def test_all_deploy_engines_have_docstrings ( self ) : <EOL> for deploy_engine in engine . Engine . get_all ( ) : <EOL> self . _assert_class_has_docstrings ( deploy_engine ) <EOL> def test_all_server_providers_have_docstrings ( self ) : <EOL> for _provider in provider . ProviderFactory . get_all ( ) : <EOL> self . _assert_class_has_docstrings ( _provider ) <EOL> def test_all_SLA_have_docstrings ( self ) : <EOL> for s in discover . itersubclasses ( sla . SLA ) : <EOL> self . _assert_class_has_docstrings ( s , long_description = False ) </s>
