From d51973a64d9f18e0dfde7601b3ffbc57571ea653 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 19 Jan 2018 09:58:18 -0500 Subject: [PATCH] ceph-volume tests add fixture helpers for call and run Signed-off-by: Alfredo Deza --- src/ceph-volume/ceph_volume/tests/conftest.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/ceph-volume/ceph_volume/tests/conftest.py b/src/ceph-volume/ceph_volume/tests/conftest.py index f5803346177d0..84b8a7dc77553 100644 --- a/src/ceph-volume/ceph_volume/tests/conftest.py +++ b/src/ceph-volume/ceph_volume/tests/conftest.py @@ -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)) -- 2.39.5