aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2015-12-29 14:57:31 -0500
committerGravatar Jon Bernard <jbernard@tuxion.com> 2015-12-29 15:02:23 -0500
commit3c4a553e4c45f5232f971d664445e07ee94a074a (patch)
tree1e2695cc4a81d193acc009af5ad83f3cea70ff6b /tests
parentcc1cb610776e0a6b8fbeba56c4d04d6f3126ee30 (diff)
downloaddotfiles-3c4a553e4c45f5232f971d664445e07ee94a074a.tar.gz
dotfiles-3c4a553e4c45f5232f971d664445e07ee94a074a.tar.bz2
dotfiles-3c4a553e4c45f5232f971d664445e07ee94a074a.zip
Add repository class rework
This version of the repository class uses py.path.local and I have an idea for packages that should simplify the code substantially and address the remaining issues with prefixes.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_repository.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_repository.py b/tests/test_repository.py
new file mode 100644
index 0000000..60c4cc4
--- /dev/null
+++ b/tests/test_repository.py
@@ -0,0 +1,38 @@
+from dotfiles.dotfile import Dotfile
+from dotfiles.repository import Repository
+
+
+def test_list(tmpdir):
+
+ repo = tmpdir.ensure("Dotfiles", dir=1)
+ name = tmpdir.join(".vimrc")
+ target = repo.ensure("vimrc")
+
+ dotfile = Dotfile(name, target)
+ repository = Repository(repo, tmpdir)
+
+ # manual discovery
+ repository.dotfiles = [dotfile, dotfile, dotfile]
+
+ expected_list = ("\n"
+ ".vimrc -> Dotfiles/vimrc (unknown)\n"
+ ".vimrc -> Dotfiles/vimrc (unknown)\n"
+ ".vimrc -> Dotfiles/vimrc (unknown)")
+
+ assert expected_list == str(repository)
+
+
+def test_discovery(tmpdir):
+
+ repo = tmpdir.ensure("Dotfiles", dir=1)
+
+ tmpdir.join('.bashrc').mksymlinkto(repo.ensure('bashrc'))
+ tmpdir.join('.vimrc').mksymlinkto(repo.ensure('vimrc'))
+
+ repository = Repository(repo, tmpdir)
+
+ expected_list = ("\n"
+ ".bashrc -> Dotfiles/bashrc (unknown)\n"
+ ".vimrc -> Dotfiles/vimrc (unknown)")
+
+ assert expected_list == str(repository)