]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests add ceph.conf stub for custom conf files
authorAlfredo Deza <adeza@redhat.com>
Mon, 12 Feb 2018 21:44:45 +0000 (16:44 -0500)
committerAlfredo Deza <adeza@redhat.com>
Thu, 15 Feb 2018 16:29:28 +0000 (11:29 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/conftest.py

index 779cc1c018bba9a83887d61d14128b244e0261ba..ba3395bfba3067673ca4b73691d1f6f60c81b54d 100644 (file)
@@ -1,7 +1,7 @@
 import os
 import pytest
 from ceph_volume.api import lvm as lvm_api
-from ceph_volume import conf
+from ceph_volume import conf, configuration
 
 
 class Capture(object):
@@ -73,6 +73,26 @@ def conf_ceph(monkeypatch):
     return apply
 
 
+@pytest.fixture
+def conf_ceph_stub(monkeypatch, tmpfile):
+    """
+    Monkeypatches ceph_volume.conf.ceph with contents from a string that are
+    written to a temporary file and then is fed through the same ceph.conf
+    loading mechanisms for testing.  Unlike ``conf_ceph`` which is just a fake,
+    we are actually loading values as seen on a ceph.conf file
+
+    This is useful when more complex ceph.conf's are needed. In the case of
+    just trying to validate a key/value behavior ``conf_ceph`` is better
+    suited.
+    """
+    def apply(contents):
+        conf_path = tmpfile(contents=contents)
+        parser = configuration.load(conf_path)
+        monkeypatch.setattr(conf, 'ceph', parser)
+        return parser
+    return apply
+
+
 @pytest.fixture
 def volumes(monkeypatch):
     monkeypatch.setattr('ceph_volume.process.call', lambda x: ('', '', 0))