From 896e0fb99d62be8f19dff79e41c9a2bd7ea723b1 Mon Sep 17 00:00:00 2001 From: Jesús García Crespo Date: Tue, 26 Feb 2013 11:44:25 -0800 Subject: Remove unneeded whitespaces and fix typo --- test_dotfiles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test_dotfiles.py') diff --git a/test_dotfiles.py b/test_dotfiles.py index 88ffe67..cce8009 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'], -- cgit v1.2.3 From 33f63740fdc9e738a9638d94f0f646c762472b89 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Thu, 27 Jun 2013 10:43:12 -0400 Subject: Add a unit test for non-existent package directories If a package is defined in .dotfilesrc and the package directory doesn't exist in the repository when you attempt to add it, an IOError exception is thrown. This test captures the failing scenario. In reference to #17. --- test_dotfiles.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test_dotfiles.py') diff --git a/test_dotfiles.py b/test_dotfiles.py index cce8009..ad4bba6 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -232,6 +232,27 @@ 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 suite(): suite = unittest.TestLoader().loadTestsFromTestCase(DotfilesTestCase) -- cgit v1.2.3 From f781dcc4a345c88cc08fad8e7bd7990d7b2b9a17 Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Wed, 31 Jul 2013 20:39:42 -0400 Subject: Add unit test for single-sync feature --- test_dotfiles.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'test_dotfiles.py') 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 -- cgit v1.2.3