aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2016-01-02 23:39:51 -0500
committerGravatar Jon Bernard <jbernard@tuxion.com> 2016-01-02 23:41:38 -0500
commit863726c2d0b747686ae906e7a6016cee23602090 (patch)
tree364068db91e16f99ed6ac4a7b6c119f634e4b9c8 /tests
parent5f674b533375511e5d19745bcf8c97024da352b6 (diff)
downloaddotfiles-863726c2d0b747686ae906e7a6016cee23602090.tar.gz
dotfiles-863726c2d0b747686ae906e7a6016cee23602090.tar.bz2
dotfiles-863726c2d0b747686ae906e7a6016cee23602090.zip
Update repository tests to match recent changes
Diffstat (limited to 'tests')
-rw-r--r--tests/test_repository.py135
1 files changed, 29 insertions, 106 deletions
diff --git a/tests/test_repository.py b/tests/test_repository.py
index c8212e6..2825b66 100644
--- a/tests/test_repository.py
+++ b/tests/test_repository.py
@@ -1,24 +1,27 @@
import os
+import py
import pytest
-from dotfiles.dotfile import Dotfile
from dotfiles.repository import Repository
def test_getters():
- repo = Repository('foo', 'bar')
+ repo = Repository('/a', '/b')
assert isinstance(repo.homedir, str)
assert isinstance(repo.repodir, str)
+ assert '/a' == repo.repodir
+ assert '/b' == repo.homedir
+
def test_setters():
- repodir = '/foo/bar'
- homedir = '/fizz/buzz'
+ repodir = py.path.local('/foo/bar')
+ homedir = py.path.local('/fizz/buzz')
- repo = Repository('foo', 'bar')
+ repo = Repository('/a', '/b')
repo.repodir = repodir
repo.homedir = homedir
@@ -27,17 +30,6 @@ def test_setters():
assert homedir == repo.homedir
-def test_custom_paths():
-
- homedir = '/foo/bar'
- repodir = '/fizz/buzz'
-
- repo = Repository(repodir, homedir)
-
- assert homedir == repo.homedir
- assert repodir == repo.repodir
-
-
def test_path_expansion():
repo = Repository('~/foo', '~/bar')
@@ -46,104 +38,35 @@ def test_path_expansion():
assert os.path.expanduser('~/bar') == repo.homedir
-def test_create_repo(tmpdir):
-
- repodir = tmpdir.join("test_create_repo")
-
- repodir.check(exists=0)
- Repository(repodir)
- repodir.check(exists=1, dir=1)
-
-
-def test_empty_status(tmpdir):
-
- repo = Repository(tmpdir.join("repo"))
-
- assert '[no dotfiles found]' == repo.status()
-
-
-def test_status_manual(tmpdir, monkeypatch):
-
- repodir = tmpdir.join("Dotfiles", dir=1)
- target = repodir.ensure("vimrc")
- name = tmpdir.ensure(".vimrc")
-
- dotfile = Dotfile(name, target)
-
- repo = Repository(repodir, tmpdir)
- monkeypatch.setattr(Repository, "_load",
- lambda self: [dotfile, dotfile, dotfile])
-
- dotfile_state = Dotfile.states['conflict']['text']
- expected_status = ("{0:<18} {1}\n"
- "{0:<18} {1}\n"
- "{0:<18} {1}".format(name.basename, dotfile_state))
-
- assert expected_status == repo.status()
-
-
-def test_status_discover(tmpdir):
-
- repodir = tmpdir.ensure("Dotfiles", dir=1)
-
- tmpdir.join('.bashrc').mksymlinkto(repodir.ensure('bashrc'))
- tmpdir.join('.inputrc').mksymlinkto(repodir.ensure('inputrc'))
- tmpdir.join('.vimrc').mksymlinkto(repodir.ensure('vimrc'))
-
- repo = Repository(repodir, tmpdir)
-
- expected_status = ("{1:<18} {0}\n"
- "{2:<18} {0}\n"
- "{3:<18} {0}".format(Dotfile.states['ok']['text'],
- '.bashrc',
- '.inputrc',
- '.vimrc'))
-
- assert expected_status == repo.status()
-
-
-def test_check(tmpdir, monkeypatch):
-
- repodir = tmpdir.join('repo')
-
- dotfile_a = Dotfile(tmpdir.join('.aaa'), repodir.join('aaa'))
- dotfile_b = Dotfile(tmpdir.join('.bbb'), repodir.join('bbb'))
- dotfile_c = Dotfile(tmpdir.join('.ccc'), repodir.join('ccc'))
-
- dotfile_b.state = Dotfile.states['ok']
-
- repo = Repository(tmpdir)
- monkeypatch.setattr(Repository, "_load",
- lambda self: [dotfile_a, dotfile_b, dotfile_c])
-
- expected_status = ("{1:<18} {0}\n"
- "{2:<18} {0}".format(Dotfile.states['error']['text'],
- dotfile_a.name.basename,
- dotfile_c.name.basename))
+def test_repodir_create(tmpdir):
- assert expected_status == repo.check()
+ repodir = tmpdir.join('test_create_repo')
+ repo = Repository(repodir)
+ assert True == repodir.check(exists=0)
+ contents = repo.contents()
+ assert [] == contents
+ assert True == repodir.check(exists=1, dir=1)
-def test_sync():
- with pytest.raises(NotImplementedError):
- Repository('todo').sync()
+def test_contents_empty(tmpdir):
+ assert [] == Repository(tmpdir.join('Dotfiles')).contents()
-def test_unsync():
- with pytest.raises(NotImplementedError):
- Repository('todo').unsync()
+def test_contents_nonempty(tmpdir):
-def test_add():
- with pytest.raises(NotImplementedError):
- Repository('todo').add()
+ repodir = tmpdir.ensure('test_create_repo', dir=1)
+ target_a = repodir.ensure('a')
+ target_b = repodir.ensure('b')
+ target_c = repodir.ensure('c')
+ contents = Repository(repodir).contents()
-def test_remove():
- with pytest.raises(NotImplementedError):
- Repository('todo').remove()
+ assert target_a == contents[0].target
+ assert target_b == contents[1].target
+ assert target_c == contents[2].target
-def test_move():
- with pytest.raises(NotImplementedError):
- Repository('todo').move()
+@pytest.mark.xfail(reason='not implemented yet')
+def test_rename():
+ raise NotImplementedError