diff options
author | Jon Bernard <jbernard@tuxion.com> | 2014-07-24 16:33:48 -0400 |
---|---|---|
committer | Jon Bernard <jbernard@tuxion.com> | 2014-07-24 16:33:48 -0400 |
commit | 4a215801542e28a6c7fdaa2d9e9679ebe911f9fe (patch) | |
tree | c853cc157e27a4e95767eda1d436e0057b833e61 | |
parent | e3ac8c34392cd75256ca0fc1dcc30101c85f68df (diff) | |
download | dotfiles-4a215801542e28a6c7fdaa2d9e9679ebe911f9fe.tar.gz dotfiles-4a215801542e28a6c7fdaa2d9e9679ebe911f9fe.tar.bz2 dotfiles-4a215801542e28a6c7fdaa2d9e9679ebe911f9fe.zip |
A few more test tweaks
-rw-r--r-- | tests/conftest.py (renamed from tests/utils.py) | 17 | ||||
-rw-r--r-- | tests/test_core.py | 26 |
2 files changed, 17 insertions, 26 deletions
diff --git a/tests/utils.py b/tests/conftest.py index ecdeb84..7fc2cc4 100644 --- a/tests/utils.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ import os +import pytest from dotfiles.utils import compare_path as samefile @@ -9,14 +10,15 @@ def _touch(fname, times=None): class HomeDirectory(object): + DEFAULT_REPOSITORY = 'dotfiles' - def __init__(self, path, repo, contents): + def __init__(self, path, repo=None, contents=None): self.path = path - self.repo = repo + 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) @@ -31,7 +33,6 @@ class HomeDirectory(object): self.verify(contents) - def verify(self, contents): __tracebackhide__ = True @@ -49,7 +50,13 @@ class HomeDirectory(object): 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)) + 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_core.py b/tests/test_core.py index a425e24..640cac9 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,33 +1,17 @@ -import os -import pytest -from utils import HomeDirectory from dotfiles.core import Dotfiles as Repository -REPOSITORY = 'dotfiles' - - -def test_sync(tmpdir): - """the quick, brown fox jumps over the lazy dog. - - lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod - tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, - quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo - consequat. duis aute irure dolor in reprehenderit in voluptate velit esse - cillum dolore eu fugiat nulla pariatur. excepteur sint occaecat cupidatat - non proident, sunt in culpa qui officia deserunt mollit anim id est - laborum""" +def test_sync(homedir): + """Basic sync operation.""" contents = {'.foo': True, '.bar': True, '.baz': False} - homedir = HomeDirectory(str(tmpdir), REPOSITORY, contents) + homedir.setup(contents) - Repository(homedir=homedir.path, - repository=os.path.join(homedir.path, REPOSITORY), - prefix='', ignore=[], externals={}, packages=[], - dry_run = False).sync() + Repository(path=homedir.repo, + homedir=homedir.path).sync() # .baz should now exist and link to the correct location contents['.baz'] = True |