From 1db47d78bf22b89a472836980db1168390471e5b Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 16 Feb 2018 10:10:23 -0500 Subject: [PATCH] [RM-21677] tests verify that directories are not used Signed-off-by: Alfredo Deza --- ceph_deploy/tests/unit/hosts/test_remotes.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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' -- 2.47.3