aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/conftest.py62
-rw-r--r--tests/test_basic.py19
-rw-r--r--tests/test_core.py18
3 files changed, 19 insertions, 80 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
deleted file mode 100644
index 7fc2cc4..0000000
--- a/tests/conftest.py
+++ /dev/null
@@ -1,62 +0,0 @@
-import os
-import pytest
-from dotfiles.utils import compare_path as samefile
-
-
-def _touch(fname, times=None):
- with open(fname, 'a'):
- os.utime(fname, times)
-
-
-class HomeDirectory(object):
-
- DEFAULT_REPOSITORY = 'dotfiles'
-
- def __init__(self, path, repo=None, contents=None):
- self.path = path
- if not repo:
- self.repo = os.path.join(path, self.DEFAULT_REPOSITORY)
- if contents:
- self.setup(contents)
-
- def setup(self, contents):
- repo = os.path.join(self.path, self.repo)
- os.mkdir(repo)
-
- for link, link_should_exist in contents.items():
-
- target = os.path.join('%s/%s' % (repo, link[1:]))
- _touch(target)
-
- if link_should_exist:
- os.symlink(target, os.path.join(self.path, link))
-
- self.verify(contents)
-
- def verify(self, contents):
- __tracebackhide__ = True
-
- for link, link_should_exist in contents.items():
-
- target = os.path.join(self.path, '%s/%s' % (self.repo, link[1:]))
-
- if not os.path.exists(target):
- pytest.fail("missing expected repo file \"%s\"" % target)
-
- link = os.path.join(self.path, link)
- link_exists = os.path.exists(link)
-
- if link_should_exist:
- if not link_exists:
- pytest.fail("missing expected symlink \"%s\"" % link)
- if not samefile(link, target):
- pytest.fail("\"%s\" does not link to \"%s\"" %
- (link, target))
-
- elif link_exists:
- pytest.fail("found unexpected symlink \"%s\"" % link)
-
-
-@pytest.fixture
-def homedir(tmpdir):
- return HomeDirectory(str(tmpdir))
diff --git a/tests/test_basic.py b/tests/test_basic.py
index 471e383..1c3a77a 100644
--- a/tests/test_basic.py
+++ b/tests/test_basic.py
@@ -37,6 +37,25 @@ class DotfilesTestCase(unittest.TestCase):
os.path.realpath(path1),
os.path.realpath(path2))
+ def test_sync(self):
+ """Basic sync operation."""
+
+ touch(os.path.join(self.repository, 'foo'))
+
+ dotfiles = Dotfiles(homedir=self.homedir,
+ path=self.repository,
+ prefix='',
+ ignore=[],
+ externals={},
+ packages=[],
+ dry_run=False)
+
+ dotfiles.sync()
+
+ self.assertPathEqual(
+ os.path.join(self.homedir, '.foo'),
+ os.path.join(self.repository, 'foo'))
+
def test_force_sync_directory(self):
"""Test forced sync when the dotfile is a directory.
diff --git a/tests/test_core.py b/tests/test_core.py
deleted file mode 100644
index 640cac9..0000000
--- a/tests/test_core.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from dotfiles.core import Dotfiles as Repository
-
-
-def test_sync(homedir):
- """Basic sync operation."""
-
- contents = {'.foo': True,
- '.bar': True,
- '.baz': False}
-
- homedir.setup(contents)
-
- Repository(path=homedir.repo,
- homedir=homedir.path).sync()
-
- # .baz should now exist and link to the correct location
- contents['.baz'] = True
- homedir.verify(contents)