コード例 #1
0
ファイル: test.py プロジェクト: east825/pot
def _test_existing(content, modified=False, force=False):
    with temp_cwd(prefix='pot-test'):
        make_hierarchy({
            'pot': {
                'dotfiles': {
                    'dotfile': ''
                },
                'config.yaml': 'dotfiles: [{name: dotfile}]'
            },
            'home': {
                'dotfile': content
            }
        })
        # default system mtime resolution is not sufficient
        # time.sleep(2)
        mgr = assert_modified if modified else assert_not_modified
        with mgr('home/dotfile'):
            with updated_env(HOME=os.path.abspath('home')):
                with cd('pot'):
                    pot.install(['dotfile'], force=force)
コード例 #2
0
ファイル: test.py プロジェクト: east825/pot
def test_install():
    config = """\
dotfiles:
- name: .vimrc
  target: ~/.vimrc
  action: symlink
- name: .bashrc
  target: ~/.bashrc
  action: include
- name: .vim
  target: ../somedir/vimfiles
  action: copy
"""
    with temp_cwd(prefix='pot-test'):
        make_hierarchy({
            'pot': {
                'dotfiles': {
                    '.vim': {},
                    '.vimrc': '1\n',
                    '.bashrc': '2\n',
                    '.gitconfig': ''
                },
                'config.yaml': config
            },
            'home': {
                '.gitconfig': 'already exists\n',
                '.bashrc': ''
            },
            'somedir': {}
        })
        with assert_not_modified('home/.gitconfig'):
            with updated_env(HOME=os.path.abspath('home')):
                with cd('pot'):
                    pot.install()
        # symlink pointing to correct location created
        eq_(os.readlink('home/.vimrc'), os.path.abspath('pot/dotfiles/.vimrc'))
        # new directory created
        ok_(os.path.isdir('somedir/vimfiles'))
        # configuration included
        eq_(open('home/.bashrc').read(), '. {}\n'.format(os.path.abspath('pot/dotfiles/.bashrc')))