diff options
author | Jon Bernard <jbernard@jbernard.io> | 2018-09-22 09:45:35 -0400 |
---|---|---|
committer | Jon Bernard <jbernard@jbernard.io> | 2018-09-22 09:45:35 -0400 |
commit | 135e9ca13e5476450047a88114497d430112cd15 (patch) | |
tree | 14d1e4ffc8ff0253c2f89a593c30d4d07a8092c1 /tests/test_dotfile.py | |
parent | 92256405ab49b3d50bd001231ea3380f8dafe343 (diff) | |
download | dotfiles-135e9ca13e5476450047a88114497d430112cd15.tar.gz dotfiles-135e9ca13e5476450047a88114497d430112cd15.tar.bz2 dotfiles-135e9ca13e5476450047a88114497d430112cd15.zip |
Clean up dotfile tests slightly
Diffstat (limited to 'tests/test_dotfile.py')
-rw-r--r-- | tests/test_dotfile.py | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/tests/test_dotfile.py b/tests/test_dotfile.py index a4584e3..6f3eb4e 100644 --- a/tests/test_dotfile.py +++ b/tests/test_dotfile.py @@ -6,26 +6,33 @@ from dotfiles.exceptions import \ IsSymlink, NotASymlink, TargetExists, TargetMissing, Exists -def _dotfile(repo, name, target=None): +def _make_dotfile(repo, name, target=None): return Dotfile(repo.homedir.join(name), repo.path.join(target if target is not None else name)) @pytest.mark.parametrize('name', ['.a']) def test_str(repo, name): - dotfile = _dotfile(repo, name, '.b') + dotfile = _make_dotfile(repo, name, '.b') assert str(dotfile) == repo.homedir.join(name) @pytest.mark.parametrize('name', ['.foo']) def test_short_name(repo, name): - dotfile = _dotfile(repo, name) + dotfile = _make_dotfile(repo, name) assert dotfile.name == repo.homedir.join(name) assert dotfile.short_name(repo.homedir) == name +def test_is_present(repo): + dotfile = _make_dotfile(repo, '.foo') + assert not dotfile.is_present() + # TODO: more + + +# {{{1 state def test_state(repo): - dotfile = _dotfile(repo, '.vimrc', 'vimrc') + dotfile = _make_dotfile(repo, '.vimrc', 'vimrc') assert dotfile.state == 'error' dotfile.target.ensure() @@ -45,9 +52,10 @@ def test_state(repo): assert dotfile.state == 'ok' +# {{{1 add @pytest.mark.parametrize('path', ['.foo', '.foo/bar/baz']) def test_add(repo, path): - dotfile = _dotfile(repo, path) + dotfile = _make_dotfile(repo, path) dotfile.target.ensure() dotfile.name.ensure() @@ -69,9 +77,10 @@ def test_add(repo, path): assert dotfile.name.samefile(dotfile.target) +# {{{1 remove @pytest.mark.parametrize('path', ['.foo', '.foo/bar/baz']) def test_remove(repo, path): - dotfile = _dotfile(repo, path) + dotfile = _make_dotfile(repo, path) py.path.local(dotfile.name.dirname).ensure_dir() dotfile.name.mksymlinkto(dotfile.target) @@ -91,9 +100,10 @@ def test_remove(repo, path): assert dotfile.name.check(file=1, link=0) +# {{{1 link @pytest.mark.parametrize('path', ['.foo', '.foo/bar/baz']) def test_link(repo, path): - dotfile = _dotfile(repo, path) + dotfile = _make_dotfile(repo, path) with pytest.raises(TargetMissing): dotfile.link() @@ -113,9 +123,10 @@ def test_link(repo, path): assert dotfile.name.samefile(dotfile.target) +# {{{1 unlink @pytest.mark.parametrize('path', ['.foo', '.foo/bar/baz']) def test_unlink(repo, path): - dotfile = _dotfile(repo, path) + dotfile = _make_dotfile(repo, path) with pytest.raises(NotASymlink): dotfile.unlink() @@ -137,3 +148,9 @@ def test_unlink(repo, path): assert dotfile.target.check(file=1, link=0) assert dotfile.name.check(exists=0) + + +# {{{1 copy +# @pytest.mark.parametrize('path', ['.foo', '.foo/bar/baz']) +# def test_unlink(repo, path): +# dotfile = _make_dotfile(repo, path) |