diff options
Diffstat (limited to 'test_dotfiles.py')
-rwxr-xr-x | test_dotfiles.py | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/test_dotfiles.py b/test_dotfiles.py index 88ffe67..babe43c 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -180,7 +180,7 @@ class DotfilesTestCase(unittest.TestCase): self.assertPathEqual( os.path.join(self.repository, original), os.path.join(self.homedir, symlink)) - + def test_packages(self): """ Test packages. @@ -197,7 +197,7 @@ class DotfilesTestCase(unittest.TestCase): os.makedirs(dirname) touch(path) - # Create Dotiles object + # Create Dotfiles object dotfiles = core.Dotfiles( homedir=self.homedir, repository=self.repository, prefix='', ignore=[], externals={}, packages=['package'], @@ -232,6 +232,74 @@ class DotfilesTestCase(unittest.TestCase): dotfiles.move(self.repository) check_all(files, symlinks) + def test_missing_package(self): + """ + Test a non-existent package. + """ + + package_file = '.package/bar' + + # Create Dotfiles object + dotfiles = core.Dotfiles( + homedir=self.homedir, repository=self.repository, + prefix='', ignore=[], externals={}, packages=['package'], + dry_run=False) + + path = os.path.join(self.homedir, package_file) + dirname = os.path.dirname(path) + if not os.path.exists(dirname): + os.makedirs(dirname) + touch(path) + + dotfiles.add([os.path.join(self.homedir, package_file)]) + + + def test_single_sync(self): + """ + Test syncing a single file in the repo + + The following repo dir exists: + + bashrc + netrc + vimrc + + Syncing only vimrc should have the folowing sync result in home: + + .vimrc -> Dotfiles/vimrc + + """ + + # define the repository contents + repo_files = ( + ('bashrc', False), + ('netrc', False), + ('vimrc', True)) + + # populate the repository + for dotfile, _ in repo_files: + touch(os.path.join(self.repository, dotfile)) + + dotfiles = core.Dotfiles( + homedir=self.homedir, repository=self.repository, + prefix='', ignore=[], externals={}, packages=[], + dry_run=False) + + # sync only certain dotfiles + for dotfile, should_sync in repo_files: + if should_sync: + dotfiles.sync(files=['.%s' % dotfile]) + + # verify home directory contents + for dotfile, should_sync in repo_files: + if should_sync: + self.assertPathEqual( + os.path.join(self.repository, dotfile), + os.path.join(self.homedir, '.%s' % dotfile)) + else: + self.assertFalse(os.path.exists( + os.path.join(self.homedir, dotfile))) + def suite(): suite = unittest.TestLoader().loadTestsFromTestCase(DotfilesTestCase) |