]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests add fixture helpers for call and run
authorAlfredo Deza <adeza@redhat.com>
Fri, 19 Jan 2018 14:58:18 +0000 (09:58 -0500)
committerAlfredo Deza <adeza@redhat.com>
Mon, 22 Jan 2018 19:43:49 +0000 (14:43 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/conftest.py

index f5803346177d0e4b4ec996f754abb20d2f01e7ce..84b8a7dc77553945372742be8148e4e82dffe404 100644 (file)
@@ -1,6 +1,7 @@
 import os
 import pytest
 from ceph_volume.api import lvm as lvm_api
+from ceph_volume import conf
 
 
 class Capture(object):
@@ -31,6 +32,34 @@ def capture():
     return Capture()
 
 
+@pytest.fixture
+def fake_run(monkeypatch):
+    fake_run = Capture()
+    monkeypatch.setattr('ceph_volume.process.run', fake_run)
+    return fake_run
+
+
+@pytest.fixture
+def fake_call(monkeypatch):
+    fake_call = Capture()
+    monkeypatch.setattr('ceph_volume.process.call', fake_call)
+    return fake_call
+
+
+@pytest.fixture
+def conf_ceph(monkeypatch):
+    """
+    Monkeypatches ceph_volume.conf.ceph, which is meant to parse/read
+    a ceph.conf. The patching is naive, it allows one to set return values for
+    specific method calls.
+    """
+    def apply(**kw):
+        stub = Factory(**kw)
+        monkeypatch.setattr(conf, 'ceph', stub)
+        return stub
+    return apply
+
+
 @pytest.fixture
 def volumes(monkeypatch):
     monkeypatch.setattr('ceph_volume.process.call', lambda x: ('', '', 0))