<s> import testtools <EOL> from shaker . engine . executors import flent <EOL> IP = '<STR_LIT>' <EOL> AGENT = { '<STR_LIT>' : { '<STR_LIT>' : IP } } <EOL> class TestFlentExecutor ( testtools . TestCase ) : <EOL> def test_get_command ( self ) : <EOL> executor = flent . FlentExecutor ( { } , AGENT ) <EOL> expected = { '<STR_LIT:data>' : ( flent . FLENT_EXEC % '<STR_LIT>' <EOL> '<STR_LIT>' ) % IP , <EOL> '<STR_LIT:type>' : '<STR_LIT>' } <EOL> self . assertEqual ( expected , executor . get_command ( ) ) <EOL> def test_get_command_with_params ( self ) : <EOL> executor = flent . FlentExecutor ( <EOL> dict ( method = '<STR_LIT>' , time = <NUM_LIT:10> , interval = <NUM_LIT:0.5> ) , AGENT ) <EOL> expected = { '<STR_LIT:data>' : ( flent . FLENT_EXEC % '<STR_LIT>' <EOL> '<STR_LIT>' ) % IP , <EOL> '<STR_LIT:type>' : '<STR_LIT>' } <EOL> self . assertEqual ( expected , executor . get_command ( ) ) <EOL> def test_get_command_static_host ( self ) : <EOL> executor = flent . FlentExecutor ( { '<STR_LIT:host>' : '<STR_LIT>' } , { } ) <EOL> expected = { '<STR_LIT:data>' : ( flent . FLENT_EXEC % '<STR_LIT>' <EOL> '<STR_LIT>' ) % '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT>' } <EOL> self . assertEqual ( expected , executor . get_command ( ) ) <EOL> def test_get_expected_duration ( self ) : <EOL> executor = flent . FlentExecutor ( dict ( method = '<STR_LIT>' , time = <NUM_LIT:10> ) , AGENT ) <EOL> expected = <NUM_LIT:20> <EOL> self . assertEqual ( expected , executor . get_expected_duration ( ) ) <EOL> def test_process_reply ( self ) : <EOL> executor = flent . FlentExecutor ( { } , AGENT ) <EOL> message = { <EOL> '<STR_LIT>' : """<STR_LIT>""" <EOL> } <EOL> expected = { <EOL> '<STR_LIT>' : [ <EOL> [ <NUM_LIT:0.0> , <NUM_LIT> , None ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , None ] <EOL> ] , <EOL> '<STR_LIT>' : [ <EOL> [ '<STR_LIT:time>' , '<STR_LIT:s>' ] , [ '<STR_LIT>' , '<STR_LIT>' ] , [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> ] <EOL> } <EOL> reply = executor . process_reply ( message ) <EOL> self . assertEqual ( expected [ '<STR_LIT>' ] , reply [ '<STR_LIT>' ] , <EOL> message = '<STR_LIT>' ) <EOL> self . assertEqual ( expected [ '<STR_LIT>' ] , reply [ '<STR_LIT>' ] , <EOL> message = '<STR_LIT>' ) </s>
