예제 #1
0
 def test_update_env_file(self, mock_path):
     file_data = ["FAKE_ENV=old_value\n", "FAKE_ENV2=any\n"]
     with mock.patch("rally.fileutils.open", mock.mock_open(read_data=file_data), create=True) as mock_file:
         mock_file.return_value.readlines.return_value = file_data
         fileutils.update_env_file("path_to_file", "FAKE_ENV", "new_value")
         calls = [mock.call("FAKE_ENV2=any\n"), mock.call("FAKE_ENV=new_value")]
         mock_file.return_value.readlines.assert_called_once_with()
         mock_file.return_value.write.assert_has_calls(calls)
예제 #2
0
 def test_update_env_file(self, mock_path):
     file_data = ["FAKE_ENV=old_value\n", "FAKE_ENV2=any\n"]
     mock_path.return_value = True
     with mock.patch('rally.fileutils.open', mock.mock_open(
             read_data=file_data), create=True) as mock_file:
         mock_file.return_value.readlines.return_value = file_data
         fileutils.update_env_file('path_to_file', 'FAKE_ENV', 'new_value')
         calls = [mock.call('FAKE_ENV2=any\n'), mock.call(
             'FAKE_ENV=new_value')]
         mock_file.return_value.readlines.assert_called_once_with()
         mock_file.return_value.write.assert_has_calls(calls)
예제 #3
0
 def test_update_env_file(self, mock_path):
     file_data = ["FAKE_ENV=old_value\n", "FAKE_ENV2=any\n"]
     with mock.patch('rally.fileutils.open',
                     mock.mock_open(read_data=file_data),
                     create=True) as mock_file:
         mock_file.return_value.readlines.return_value = file_data
         fileutils.update_env_file('path_to_file', 'FAKE_ENV', 'new_value')
         calls = [
             mock.call('FAKE_ENV2=any\n'),
             mock.call('FAKE_ENV=new_value')
         ]
         mock_file.return_value.readlines.assert_called_once_with()
         mock_file.return_value.write.assert_has_calls(calls)
예제 #4
0
파일: envutils.py 프로젝트: sahanasj/rally
def clear_global(global_key):
    path = os.path.expanduser('~/.rally/globals')
    if os.path.exists(path):
        fileutils.update_env_file(path, global_key, '\n')
    if global_key in os.environ:
        os.environ.pop(global_key)
예제 #5
0
파일: use.py 프로젝트: dlenwell/rally
 def _update_attribute_in_global_file(self, attribute, value):
     expanded_path = os.path.expanduser('~/.rally/globals')
     fileutils.update_env_file(expanded_path, attribute, '%s\n' % value)
예제 #6
0
파일: use.py 프로젝트: sahanasj/rally
 def _update_attribute_in_global_file(self, attribute, value):
     expanded_path = os.path.expanduser('~/.rally/globals')
     fileutils.update_env_file(expanded_path, attribute, '%s\n' % value)
예제 #7
0
def clear_global(global_key):
    path = os.path.expanduser('~/.rally/globals')
    if os.path.exists(path):
        fileutils.update_env_file(path, global_key, '\n')
    if global_key in os.environ:
        os.environ.pop(global_key)