]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
add tests for new 'which' remote helper
authorAlfredo Deza <alfredo.deza@inktank.com>
Mon, 25 Nov 2013 17:27:21 +0000 (11:27 -0600)
committerAlfredo Deza <alfredo.deza@inktank.com>
Mon, 25 Nov 2013 17:27:21 +0000 (11:27 -0600)
Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
ceph_deploy/tests/test_remotes.py [new file with mode: 0644]

diff --git a/ceph_deploy/tests/test_remotes.py b/ceph_deploy/tests/test_remotes.py
new file mode 100644 (file)
index 0000000..42d23b1
--- /dev/null
@@ -0,0 +1,32 @@
+from mock import patch
+from ceph_deploy.hosts import remotes
+
+
+class FakeExists(object):
+
+    def __init__(self, existing_paths):
+        self.existing_paths = existing_paths
+
+    def __call__(self, path):
+        for existing_path in self.existing_paths:
+            if path == existing_path:
+                return path
+
+
+class TestWhich(object):
+
+    def setup(self):
+        self.exists_module = 'ceph_deploy.hosts.remotes.os.path.exists'
+
+    def test_finds_absolute_paths(self):
+        exists = FakeExists(['/bin/ls'])
+        with patch(self.exists_module, exists):
+            path = remotes.which('ls')
+        assert path == '/bin/ls'
+
+    def test_does_not_find_executable(self):
+        exists = FakeExists(['/bin/foo'])
+        with patch(self.exists_module, exists):
+            path = remotes.which('ls')
+        assert path is None
+