summaryrefslogtreecommitdiffstats
path: root/test_dotfiles.py
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2013-11-07 09:39:42 -0500
committerGravatar Jon Bernard <jbernard@tuxion.com> 2013-11-07 09:39:42 -0500
commit2b3ff6e5f524b5aea0a31689e08e204e4fae0b36 (patch)
tree6c853a735574f8b47d8119c8680f8cc3467bc0b5 /test_dotfiles.py
parentc97f331ea2ebe7ae46ea04f81cfc01eba7ef7a75 (diff)
parente04b5e6cb601bce8c5e3db1b6dd998158d7d4b42 (diff)
downloaddotfiles-2b3ff6e5f524b5aea0a31689e08e204e4fae0b36.tar.gz
dotfiles-2b3ff6e5f524b5aea0a31689e08e204e4fae0b36.tar.bz2
dotfiles-2b3ff6e5f524b5aea0a31689e08e204e4fae0b36.zip
Merge branch 'feature/single-sync'
Diffstat (limited to 'test_dotfiles.py')
-rwxr-xr-xtest_dotfiles.py72
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)