From: Alfredo Deza Date: Mon, 25 Nov 2013 17:27:21 +0000 (-0600) Subject: add tests for new 'which' remote helper X-Git-Tag: v1.3.3~4^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0f9cef683825c11e0753d76d8af83e30a80c4eed;p=ceph-deploy.git add tests for new 'which' remote helper Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/tests/test_remotes.py b/ceph_deploy/tests/test_remotes.py new file mode 100644 index 0000000..42d23b1 --- /dev/null +++ b/ceph_deploy/tests/test_remotes.py @@ -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 +