From 3b7a6968d9be240c4ad4ec3d92bb99bc7fd888ef Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Fri, 1 Jan 2016 08:54:14 -0500 Subject: Implement dotfile state management --- tests/test_dotfile.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'tests/test_dotfile.py') 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() -- cgit v1.2.3