]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[RM-21677] tests verify that directories are not used RM-21677 465/head
authorAlfredo Deza <adeza@redhat.com>
Fri, 16 Feb 2018 15:10:23 +0000 (10:10 -0500)
committerAlfredo Deza <adeza@redhat.com>
Fri, 16 Feb 2018 15:10:23 +0000 (10:10 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
ceph_deploy/tests/unit/hosts/test_remotes.py

index d081917e7cf3afdf940175e8d74b10e08c95a0c5..69ee4f78536a29906c821f7026f2dc769806d776 100644 (file)
@@ -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'