コード例 #1
0
    def test_move_repository(self):
        """Test the move() method for a Dotfiles repository."""

        touch(os.path.join(self.repository, 'bashrc'))

        dotfiles = Dotfiles(
                homedir=self.homedir, path=self.repository,
                prefix='', ignore=[], force=True, externals={}, packages=[],
                dry_run=False)

        dotfiles.sync()

        # Make sure sync() did the right thing.
        self.assertPathEqual(
                os.path.join(self.homedir, '.bashrc'),
                os.path.join(self.repository, 'bashrc'))

        target = os.path.join(self.homedir, 'MyDotfiles')

        dotfiles.move(target)

        self.assertTrue(os.path.exists(os.path.join(target, 'bashrc')))
        self.assertPathEqual(
                os.path.join(self.homedir, '.bashrc'),
                os.path.join(target, 'bashrc'))
コード例 #2
0
    def test_packages(self):
        """
        Test packages.
        """
        files = ['foo', 'package/bar']
        symlinks = ['.foo', '.package/bar']
        join = os.path.join

        # Create files
        for filename in files:
            path = join(self.repository, filename)
            dirname = os.path.dirname(path)
            if not os.path.exists(dirname):
                os.makedirs(dirname)
            touch(path)

        # Create Dotfiles object
        dotfiles = Dotfiles(homedir=self.homedir,
                            path=self.repository,
                            prefix='',
                            ignore=[],
                            externals={},
                            packages=['package'],
                            dry_run=False)

        # Create symlinks in homedir
        dotfiles.sync()

        # Verify it created what we expect
        def check_all(files, symlinks):
            self.assertTrue(os.path.isdir(join(self.homedir, '.package')))
            for src, dst in zip(files, symlinks):
                self.assertTrue(
                    is_link_to(join(self.homedir, dst),
                               join(self.repository, src)))

        check_all(files, symlinks)

        # Add files to the repository
        new_files = [join(self.homedir, f) for f in ['.bar', '.package/foo']]
        for filename in new_files:
            path = join(self.homedir, filename)
            touch(path)
        new_repo_files = ['bar', 'package/foo']
        dotfiles.add(new_files)
        check_all(files + new_repo_files, symlinks + new_files)

        # Remove them from the repository
        dotfiles.remove(new_files)
        check_all(files, symlinks)

        # Move the repository
        self.repository = join(self.homedir, 'Dotfiles2')
        dotfiles.move(self.repository)
        check_all(files, symlinks)
コード例 #3
0
ファイル: test_basic.py プロジェクト: jeffrey4l/dotfiles
    def test_packages(self):
        """
        Test packages.
        """
        files = ['foo', 'package/bar', 'package2/foo/bar']
        symlinks = ['.foo', '.package/bar', '.package2/foo/bar']
        join = os.path.join

        # Create files
        for filename in files:
            path = join(self.repository, filename)
            dirname = os.path.dirname(path)
            if not os.path.exists(dirname):
                os.makedirs(dirname)
            touch(path)

        # Create Dotfiles object
        dotfiles = Dotfiles(
                homedir=self.homedir, path=self.repository,
                prefix='', ignore=[], externals={},
                packages=set(['package', 'package2/foo']), dry_run=False)

        # Create symlinks in homedir
        dotfiles.sync()

        # Verify it created what we expect
        for folder in ['.package', '.package2', '.package2/foo']:
            self.assertTrue(os.path.isdir(join(self.homedir, folder)))
        def check_all(files, symlinks):
            for src, dst in zip(files, symlinks):
                self.assertTrue(is_link_to(join(self.homedir, dst),
                    join(self.repository, src)))
        check_all(files, symlinks)

        # Add files to the repository
        new_files = [join(self.homedir, f) for f in 
                ['.bar', '.package/foo', '.package2/foo/bar2']]
        for filename in new_files:
            path = join(self.homedir, filename)
            touch(path)
        new_repo_files = ['bar', 'package/foo', 'package2/foo/bar2']
        dotfiles.add(new_files)
        check_all(files + new_repo_files, symlinks + new_files)

        # Remove them from the repository
        dotfiles.remove(new_files)
        check_all(files, symlinks)

        # Move the repository
        self.repository = join(self.homedir, 'Dotfiles2')
        dotfiles.move(self.repository)
        check_all(files, symlinks)