示例#1
0
def test_get_dot_files(listdir_mock, isfile_mock):
    files = ['testfile', '.no_file', '.good_file']
    listdir_mock.return_value = files
    isfile_mock.return_value = True
    home_dir = get_home_dir()
    result = dotfiles.get_dot_files(home_dir)
    assert result[0] == path.join(home_dir, files[1])
示例#2
0
def test_restore(copy_files_mock, dotfiles_mock, ensure_mock):
    files = ['.no_file']
    dest = get_home_dir()
    dotfiles_mock.return_value = files
    dotfiles.restore()
    copy_files_mock.assert_called_with(files, dest)
    ensure_mock.assert_called_with(get_user(), files)
示例#3
0
def backup():
    print 'Backing up dotfiles...'
    # build file list
    home_dir = get_home_dir()
    excludes = get_dotfile_excludes()
    files = get_dot_files(home_dir, excludes)
    dest = get_dotfiles_backup_dir()
    copy_files(files, dest)
示例#4
0
def restore():
    print 'Restoring dotfiles...'
    source = get_dotfiles_backup_dir()
    dest = get_home_dir()
    files = get_dot_files(source)
    copy_files(files, dest)
    files = get_dot_files(dest)
    ensure_files_owned_by_user(get_user(), files)
示例#5
0
 def fill_pref(self):
     cfg = config.tp_cfg()
     if not cfg.load():
         self.ab_entry.set_text(API_BASE)
         self.ob_entry.set_text(OAUTH_BASE)
         self.op_entry.set_text(config.get_home_dir())
         self.lc_entry.set_text('blue')
     else:
         self.ab_entry.set_text(cfg.api_base)
         self.ob_entry.set_text(cfg.oauth_base)
         self.op_entry.set_text(cfg.output_path)
         self.fn_entry.set_text(cfg.font_path)
         self.lc_entry.set_text(cfg.link_color)
         self.hp_enable.set_active(cfg.proxy_enable)
         self.ph_entry.set_text(cfg.proxy_host)
         self.pp_entry.set_text(cfg.proxy_port)
示例#6
0
 def reset_btn_clicked(self, widget, data = None):
     cfg = config.tp_cfg()        
     cfg.set_api_base(API_BASE)
     cfg.set_oauth_base(OAUTH_BASE)
     cfg.set_output_path(config.get_home_dir())
     cfg.set_link_color('blue')
     cfg.set_proxy_enable(False)
     cfg.set_proxy_host('')
     cfg.set_proxy_port('')
     cfg.save()
     self.hp_enable.set_active(cfg.proxy_enable)
     self.ab_entry.set_text(cfg.api_base)
     self.ob_entry.set_text(cfg.oauth_base)
     self.fn_entry.set_text(cfg.font_path)
     self.op_entry.set_text(cfg.output_path)
     self.lc_entry.set_text(cfg.link_color)
     self.ph_entry.set_text(cfg.proxy_host)
     self.pp_entry.set_text(cfg.proxy_port)
示例#7
0
def test_get_app_store_preferences_dir():
    assert config.get_app_store_preferences_dir() == path.join(
        config.get_home_dir(), 'Library/Containers/')
示例#8
0
def test_get_shared_file_lists_dir():
    path.join(config.get_home_dir(),
              'Library/Application Support/com.apple.sharedfilelist/')
示例#9
0
def test_get_ssh_user_dir():
    assert config.get_ssh_user_dir() == path.join(config.get_home_dir(),
                                                  '.ssh/')
示例#10
0
def test_get_preferences_dir():
    assert config.get_preferences_dir() == path.join(config.get_home_dir(),
                                                     'Library/Preferences/')