<s> import os <EOL> import mock <EOL> from rally . common import fileutils <EOL> from tests . unit import test <EOL> class FileUtilsTestCase ( test . TestCase ) : <EOL> @ mock . patch ( "<STR_LIT>" , return_value = True ) <EOL> @ mock . patch . dict ( "<STR_LIT>" , values = { } , clear = True ) <EOL> def test_load_env_vile ( self , mock_exists ) : <EOL> file_data = [ "<STR_LIT>" ] <EOL> with mock . patch ( "<STR_LIT>" , mock . mock_open ( <EOL> read_data = file_data ) , create = True ) as mock_file : <EOL> mock_file . return_value . readlines . return_value = file_data <EOL> fileutils . load_env_file ( "<STR_LIT>" ) <EOL> self . assertIn ( "<STR_LIT>" , os . environ ) <EOL> mock_file . return_value . readlines . assert_called_once_with ( ) <EOL> @ mock . patch ( "<STR_LIT>" , return_value = True ) <EOL> def test_update_env_file ( self , mock_exists ) : <EOL> file_data = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> with mock . patch ( "<STR_LIT>" , mock . mock_open ( <EOL> read_data = file_data ) , create = True ) as mock_file : <EOL> mock_file . return_value . readlines . return_value = file_data <EOL> fileutils . update_env_file ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> calls = [ mock . call ( "<STR_LIT>" ) , mock . call ( <EOL> "<STR_LIT>" ) ] <EOL> mock_file . return_value . readlines . assert_called_once_with ( ) <EOL> mock_file . return_value . write . assert_has_calls ( calls ) <EOL> class PackDirTestCase ( test . TestCase ) : <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_pack_dir ( self , mock_zip_file , mock_walk ) : <EOL> mock_walk . side_effect = [ <EOL> [ ( "<STR_LIT>" , [ ] , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) ] ] <EOL> fileutils . pack_dir ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> mock_zip_file . assert_called_once_with ( "<STR_LIT>" , <EOL> mode = "<STR_LIT:w>" ) <EOL> mock_walk . assert_called_once_with ( <EOL> "<STR_LIT>" ) <EOL> mock_zip_file . return_value . assert_has_calls ( <EOL> [ mock . call . write ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> mock . call . write ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> mock . call . write ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> mock . call . close ( ) ] ) </s>
