From 9832e47a2d3071023ed828df24f44d5a3258626a Mon Sep 17 00:00:00 2001 From: Luper Rouch Date: Sat, 9 Feb 2013 15:49:03 +0100 Subject: fixed tests --- test_dotfiles.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'test_dotfiles.py') diff --git a/test_dotfiles.py b/test_dotfiles.py index b892003..2bfdb8b 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -52,7 +52,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 +68,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 +113,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 +163,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 +179,8 @@ class DotfilesTestCase(unittest.TestCase): self.assertPathEqual( os.path.join(self.repository, original), os.path.join(self.homedir, symlink)) + + def suite(): suite = unittest.TestLoader().loadTestsFromTestCase(DotfilesTestCase) -- cgit v1.2.3 From 08e02ef848e9af19592bf4ba809dc7574592fff2 Mon Sep 17 00:00:00 2001 From: Luper Rouch Date: Sat, 9 Feb 2013 16:34:07 +0100 Subject: added packages tests --- test_dotfiles.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'test_dotfiles.py') diff --git a/test_dotfiles.py b/test_dotfiles.py index 2bfdb8b..4ecb9d7 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): @@ -180,6 +181,56 @@ class DotfilesTestCase(unittest.TestCase): 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(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(): -- cgit v1.2.3 From 23775a043edca5c979b3d47288364d0484e7a919 Mon Sep 17 00:00:00 2001 From: Luper Rouch Date: Sat, 9 Feb 2013 18:35:34 +0100 Subject: typo in test --- test_dotfiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test_dotfiles.py') diff --git a/test_dotfiles.py b/test_dotfiles.py index 4ecb9d7..88ffe67 100755 --- a/test_dotfiles.py +++ b/test_dotfiles.py @@ -208,7 +208,7 @@ class DotfilesTestCase(unittest.TestCase): # Verify it created what we expect def check_all(files, symlinks): - self.assertTrue(join(self.homedir, '.package')) + 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))) -- cgit v1.2.3