#NEWLINE# def gen_test_case( self ) : #NEWLINE# #INDENT# self . log . debug ( 'Generating Test Case test method' ) #NEWLINE# imports = self . add_imports ( ) #NEWLINE# self . root . append ( imports ) #NEWLINE# test_class = self . gen_class_definition ( 'TestRequests' , [ 'unittest.TestCase' ] ) #NEWLINE# self . root . append ( test_class ) #NEWLINE# test_class . append ( self . gen_setup_method ( ) ) #NEWLINE# requests = self . scenario . get_requests ( ) #NEWLINE# test_method = self . gen_test_method ( ) #NEWLINE# test_class . append ( test_method ) #NEWLINE# scenario_timeout = self . scenario . get ( 'timeout' , 30 ) #NEWLINE# for req in requests : #NEWLINE# #INDENT# test_method . append ( self . gen_comment ( ( 'start request: %s' % req . url ) ) ) #NEWLINE# if ( req . timeout is not None ) : #NEWLINE# #INDENT# test_method . append ( self . gen_impl_wait ( req . timeout ) ) #NEWLINE# #UNINDENT# test_method . append ( self . gen_method_statement ( ( "self.driver.get('%s')" % req . url ) ) ) #NEWLINE# think_time = ( req . think_time if req . think_time else self . scenario . get ( 'think-time' , None ) ) #NEWLINE# if ( think_time is not None ) : #NEWLINE# #INDENT# test_method . append ( self . gen_method_statement ( ( 'sleep(%s)' % dehumanize_time ( requests ) ) ) ) #NEWLINE# #UNINDENT# if ( 'assert' in req . config ) : #NEWLINE# #INDENT# test_method . append ( self . __gen_assert_page ( ) ) #NEWLINE# for assert_config in req . config . get ( 'assert' ) : #NEWLINE# #INDENT# test_method . extend ( self . gen_assertion ( assert_config ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( req . timeout is not None ) : #NEWLINE# #INDENT# test_method . append ( self . gen_impl_wait ( scenario_timeout ) ) #NEWLINE# #UNINDENT# test_method . append ( self . gen_comment ( ( 'end request: %s' % req . url ) ) ) #NEWLINE# test_method . append ( self . __gen_new_line ( ) ) #NEWLINE# #UNINDENT# test_class . append ( self . gen_teardown_method ( ) )