From: Alfredo Deza Date: Fri, 16 Feb 2018 15:10:23 +0000 (-0500) Subject: [RM-21677] tests verify that directories are not used X-Git-Tag: v2.0.1~8^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1db47d78bf22b89a472836980db1168390471e5b;p=ceph-deploy.git [RM-21677] tests verify that directories are not used Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/tests/unit/hosts/test_remotes.py b/ceph_deploy/tests/unit/hosts/test_remotes.py index d081917..69ee4f7 100644 --- a/ceph_deploy/tests/unit/hosts/test_remotes.py +++ b/ceph_deploy/tests/unit/hosts/test_remotes.py @@ -17,3 +17,21 @@ class TestObjectGrep(object): def test_does_not_find_anything(self): assert remotes.object_grep('bar', self.file_object) is False + + +class TestWhich(object): + + def test_executable_is_a_directory(self, monkeypatch): + monkeypatch.setattr(remotes.os.path, 'exists', lambda x: True) + monkeypatch.setattr(remotes.os.path, 'isfile', lambda x: False) + assert remotes.which('foo') is None + + def test_executable_does_not_exist(self, monkeypatch): + monkeypatch.setattr(remotes.os.path, 'exists', lambda x: False) + monkeypatch.setattr(remotes.os.path, 'isfile', lambda x: True) + assert remotes.which('foo') is None + + def test_executable_exists_as_file(self, monkeypatch): + monkeypatch.setattr(remotes.os.path, 'exists', lambda x: True) + monkeypatch.setattr(remotes.os.path, 'isfile', lambda x: True) + assert remotes.which('foo') == '/usr/local/bin/foo'