From: Alfredo Deza Date: Mon, 12 Feb 2018 21:44:45 +0000 (-0500) Subject: ceph-volume tests add ceph.conf stub for custom conf files X-Git-Tag: v12.2.3~2^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c586a24e91ca627449452103d562b6be1fbfcb4d;p=ceph.git ceph-volume tests add ceph.conf stub for custom conf files Signed-off-by: Alfredo Deza (cherry picked from commit a8eecc64716564479308fafba5159e271c42feac) --- diff --git a/src/ceph-volume/ceph_volume/tests/conftest.py b/src/ceph-volume/ceph_volume/tests/conftest.py index 779cc1c018b..ba3395bfba3 100644 --- a/src/ceph-volume/ceph_volume/tests/conftest.py +++ b/src/ceph-volume/ceph_volume/tests/conftest.py @@ -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))