def test_update_env_file(self, mock_exists):
     file_data = "FAKE_ENV=old_value\nFAKE_ENV2=any\n"
     with mock.patch("rally.common.fileutils.open", mock.mock_open(
             read_data=file_data), create=True) as mock_file:
         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)
Example #2
0
def clear_global(global_key):
    path = os.path.expanduser(PATH_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)
Example #3
0
def clear_global(global_key):
    path = os.path.expanduser(PATH_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)
Example #4
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)
Example #5
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)
Example #6
0
 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)