<s> import mock <EOL> from rally . plugins . openstack . scenarios . tempest import tempest <EOL> from rally . plugins . openstack . scenarios . tempest import utils <EOL> from tests . unit import test <EOL> TS = "<STR_LIT>" <EOL> class TempestLogWrappersTestCase ( test . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TempestLogWrappersTestCase , self ) . setUp ( ) <EOL> verifier = mock . MagicMock ( ) <EOL> verifier . parse_results . return_value = mock . MagicMock ( <EOL> total = { "<STR_LIT:time>" : <NUM_LIT:0> } , tests = { } ) <EOL> context = test . get_test_context ( ) <EOL> context . update ( { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : verifier } ) <EOL> self . scenario = tempest . TempestScenario ( context ) <EOL> self . scenario . _add_atomic_actions = mock . MagicMock ( ) <EOL> @ mock . patch ( TS + "<STR_LIT>" ) <EOL> def test_launch_without_specified_log_file ( self , mock_tempfile ) : <EOL> mock_tempfile . NamedTemporaryFile ( ) . name = "<STR_LIT>" <EOL> target_func = mock . MagicMock ( ) <EOL> target_func . __name__ = "<STR_LIT>" <EOL> func = utils . tempest_log_wrapper ( target_func ) <EOL> func ( self . scenario ) <EOL> target_func . assert_called_once_with ( self . scenario , <EOL> log_file = "<STR_LIT>" ) <EOL> @ mock . patch ( TS + "<STR_LIT>" ) <EOL> def test_launch_with_specified_log_file ( self , mock_tempfile ) : <EOL> target_func = mock . MagicMock ( ) <EOL> target_func . __name__ = "<STR_LIT>" <EOL> func = utils . tempest_log_wrapper ( target_func ) <EOL> func ( self . scenario , log_file = "<STR_LIT>" ) <EOL> target_func . assert_called_once_with ( self . scenario , <EOL> log_file = "<STR_LIT>" ) <EOL> self . assertEqual ( <NUM_LIT:0> , mock_tempfile . NamedTemporaryFile . call_count ) <EOL> def test_func_time_result_is_string ( self ) : <EOL> verifier = mock . MagicMock ( ) <EOL> verifier . parse_results . return_value = mock . MagicMock ( <EOL> total = { "<STR_LIT:time>" : "<STR_LIT>" } , tests = { } ) <EOL> context = test . get_test_context ( ) <EOL> context . update ( { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : verifier } ) <EOL> scenario = tempest . TempestScenario ( context ) <EOL> target_func = mock . MagicMock ( ) <EOL> target_func . __name__ = "<STR_LIT>" <EOL> func = utils . tempest_log_wrapper ( target_func ) <EOL> func ( scenario ) <EOL> self . assertEqual ( <NUM_LIT:0.1> , scenario . _atomic_actions [ "<STR_LIT>" ] ) </s>
