diff options
author | Jon Bernard <jbernard@tuxion.com> | 2013-07-31 20:39:42 -0400 |
---|---|---|
committer | Jon Bernard <jbernard@tuxion.com> | 2013-11-07 09:38:44 -0500 |
commit | f781dcc4a345c88cc08fad8e7bd7990d7b2b9a17 (patch) | |
tree | 03996c7490114367776f8903ee6d626ff849534a /test_dotfiles.py | |
parent | 6676d85be6285826b9c1df73ce878ba9c667489d (diff) | |
download | dotfiles-f781dcc4a345c88cc08fad8e7bd7990d7b2b9a17.tar.gz dotfiles-f781dcc4a345c88cc08fad8e7bd7990d7b2b9a17.tar.bz2 dotfiles-f781dcc4a345c88cc08fad8e7bd7990d7b2b9a17.zip |
Add unit test for single-sync feature
Diffstat (limited to 'test_dotfiles.py')
-rwxr-xr-x | test_dotfiles.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test_dotfiles.py b/test_dotfiles.py index ad4bba6..babe43c 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -254,6 +254,53 @@ class DotfilesTestCase(unittest.TestCase): 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) return suite |