aboutsummaryrefslogtreecommitdiffstats
path: root/test_dotfiles.py
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2013-02-11 12:23:18 -0500
committerGravatar Jon Bernard <jbernard@tuxion.com> 2013-02-11 12:23:18 -0500
commitc97f331ea2ebe7ae46ea04f81cfc01eba7ef7a75 (patch)
tree2d0677eb68d6292984fecb711b3eacaa4e26ee6f /test_dotfiles.py
parent613b81dd22fde850c04d3b3a26c609555ca9d194 (diff)
parent088543ecc6435ea45d2f102a5e5ac015a4782275 (diff)
downloaddotfiles-c97f331ea2ebe7ae46ea04f81cfc01eba7ef7a75.tar.gz
dotfiles-c97f331ea2ebe7ae46ea04f81cfc01eba7ef7a75.tar.bz2
dotfiles-c97f331ea2ebe7ae46ea04f81cfc01eba7ef7a75.zip
Merge branch 'release/0.6.0'v0.6.0
Diffstat (limited to 'test_dotfiles.py')
-rwxr-xr-xtest_dotfiles.py64
1 files changed, 60 insertions, 4 deletions
diff --git a/test_dotfiles.py b/test_dotfiles.py
index b892003..88ffe67 100755
--- a/test_dotfiles.py
+++ b/test_dotfiles.py
@@ -9,6 +9,7 @@ import tempfile
import unittest
from dotfiles import core
+from dotfiles.utils import is_link_to
def touch(fname, times=None):
@@ -52,7 +53,8 @@ class DotfilesTestCase(unittest.TestCase):
dotfiles = core.Dotfiles(
homedir=self.homedir, repository=self.repository,
- prefix='', ignore=[], externals=externals)
+ prefix='', ignore=[], externals=externals, packages=[],
+ dry_run=False)
dotfiles.sync(force=True)
@@ -67,7 +69,8 @@ class DotfilesTestCase(unittest.TestCase):
dotfiles = core.Dotfiles(
homedir=self.homedir, repository=self.repository,
- prefix='', ignore=[], force=True, externals={})
+ prefix='', ignore=[], force=True, externals={}, packages=[],
+ dry_run=False)
dotfiles.sync()
@@ -111,7 +114,7 @@ class DotfilesTestCase(unittest.TestCase):
dotfiles = core.Dotfiles(
homedir=self.homedir, repository=self.repository,
- prefix='', ignore=[], externals={})
+ prefix='', ignore=[], externals={}, packages=[], dry_run=False)
dotfiles.sync(force=True)
@@ -161,7 +164,8 @@ class DotfilesTestCase(unittest.TestCase):
dotfiles = core.Dotfiles(
homedir=self.homedir, repository=self.repository,
- prefix='', ignore=ignore, externals={})
+ prefix='', ignore=ignore, externals={}, packages=[],
+ dry_run=False)
dotfiles.sync()
@@ -176,6 +180,58 @@ class DotfilesTestCase(unittest.TestCase):
self.assertPathEqual(
os.path.join(self.repository, original),
os.path.join(self.homedir, symlink))
+
+ 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 Dotiles object
+ dotfiles = core.Dotfiles(
+ homedir=self.homedir, repository=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)
+
def suite():
suite = unittest.TestLoader().loadTestsFromTestCase(DotfilesTestCase)