aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_dotfile.py56
-rw-r--r--tests/test_repository.py28
2 files changed, 69 insertions, 15 deletions
diff --git a/tests/test_dotfile.py b/tests/test_dotfile.py
index 7b99db1..29908ba 100644
--- a/tests/test_dotfile.py
+++ b/tests/test_dotfile.py
@@ -73,7 +73,53 @@ def test_sync(tmpdir, times):
assert name.samefile(target)
-def test_valid(tmpdir):
+def test_state_error(tmpdir):
+
+ repo = tmpdir.ensure("Dotfiles", dir=1)
+ name = tmpdir.join(".vimrc")
+ target = repo.join("vimrc")
+
+ dotfile = Dotfile(name, target)
+
+ assert Dotfile.states['error'] == dotfile.state
+
+
+def test_state_missing(tmpdir):
+
+ repo = tmpdir.ensure("Dotfiles", dir=1)
+ name = tmpdir.join(".vimrc")
+ target = repo.ensure("vimrc")
+
+ dotfile = Dotfile(name, target)
+
+ assert Dotfile.states['missing'] == dotfile.state
+
+
+def test_state_conflict(tmpdir):
+
+ repo = tmpdir.ensure("Dotfiles", dir=1)
+ name = tmpdir.ensure(".vimrc")
+ target = repo.ensure("vimrc")
+
+ dotfile = Dotfile(name, target)
+
+ assert Dotfile.states['conflict'] == dotfile.state
+
+
+def test_state_ok(tmpdir):
+
+ repo = tmpdir.join("Dotfiles", dir=1)
+ name = tmpdir.join(".vimrc")
+ target = repo.ensure("vimrc")
+
+ name.mksymlinkto(target)
+
+ dotfile = Dotfile(name, target)
+
+ assert Dotfile.states['ok'] == dotfile.state
+
+
+def test_is_ok(tmpdir):
repo = tmpdir.join("Dotfiles", dir=1)
name = tmpdir.join(".vimrc")
@@ -82,8 +128,8 @@ def test_valid(tmpdir):
dotfile = Dotfile(name, target)
- assert '(unknown)' == dotfile.state
- assert True == dotfile.invalid()
+ assert Dotfile.states['ok'] == dotfile.state
+ assert True == dotfile.is_ok()
- dotfile.state = '(ok)'
- assert False == dotfile.invalid()
+ dotfile.state = Dotfile.states['conflict']
+ assert False == dotfile.is_ok()
diff --git a/tests/test_repository.py b/tests/test_repository.py
index 8e6b48b..c8212e6 100644
--- a/tests/test_repository.py
+++ b/tests/test_repository.py
@@ -65,8 +65,8 @@ def test_empty_status(tmpdir):
def test_status_manual(tmpdir, monkeypatch):
repodir = tmpdir.join("Dotfiles", dir=1)
- name = tmpdir.join(".vimrc")
target = repodir.ensure("vimrc")
+ name = tmpdir.ensure(".vimrc")
dotfile = Dotfile(name, target)
@@ -74,9 +74,10 @@ def test_status_manual(tmpdir, monkeypatch):
monkeypatch.setattr(Repository, "_load",
lambda self: [dotfile, dotfile, dotfile])
- expected_status = (".vimrc -> Dotfiles/vimrc (unknown)\n"
- ".vimrc -> Dotfiles/vimrc (unknown)\n"
- ".vimrc -> Dotfiles/vimrc (unknown)")
+ 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()
@@ -91,9 +92,12 @@ def test_status_discover(tmpdir):
repo = Repository(repodir, tmpdir)
- expected_status = (".bashrc -> Dotfiles/bashrc (unknown)\n"
- ".inputrc -> Dotfiles/inputrc (unknown)\n"
- ".vimrc -> Dotfiles/vimrc (unknown)")
+ 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()
@@ -106,14 +110,18 @@ def test_check(tmpdir, monkeypatch):
dotfile_b = Dotfile(tmpdir.join('.bbb'), repodir.join('bbb'))
dotfile_c = Dotfile(tmpdir.join('.ccc'), repodir.join('ccc'))
- dotfile_b.state = '(ok)'
+ dotfile_b.state = Dotfile.states['ok']
repo = Repository(tmpdir)
monkeypatch.setattr(Repository, "_load",
lambda self: [dotfile_a, dotfile_b, dotfile_c])
- assert ('.aaa -> repo/aaa (unknown)\n'
- '.ccc -> repo/ccc (unknown)') == repo.check()
+ expected_status = ("{1:<18} {0}\n"
+ "{2:<18} {0}".format(Dotfile.states['error']['text'],
+ dotfile_a.name.basename,
+ dotfile_c.name.basename))
+
+ assert expected_status == repo.check()
def test_sync():