]>
Commit | Line | Data |
---|---|---|
d2e6a577 | 1 | import pytest |
181888fb | 2 | from ceph_volume.devices.lvm import api |
d2e6a577 FG |
3 | |
4 | class Capture(object): | |
5 | ||
6 | def __init__(self, *a, **kw): | |
7 | self.a = a | |
8 | self.kw = kw | |
9 | self.calls = [] | |
10 | ||
11 | def __call__(self, *a, **kw): | |
12 | self.calls.append({'args': a, 'kwargs': kw}) | |
13 | ||
14 | ||
15 | @pytest.fixture | |
16 | def capture(): | |
17 | return Capture() | |
181888fb FG |
18 | |
19 | ||
20 | @pytest.fixture | |
21 | def volumes(monkeypatch): | |
22 | monkeypatch.setattr('ceph_volume.process.call', lambda x: ('', '', 0)) | |
23 | volumes = api.Volumes() | |
24 | volumes._purge() | |
25 | return volumes | |
26 | ||
27 | ||
28 | @pytest.fixture | |
29 | def volume_groups(monkeypatch): | |
30 | monkeypatch.setattr('ceph_volume.process.call', lambda x: ('', '', 0)) | |
31 | vgs = api.VolumeGroups() | |
32 | vgs._purge() | |
33 | return vgs | |
34 | ||
35 | ||
36 | @pytest.fixture | |
37 | def is_root(monkeypatch): | |
38 | """ | |
39 | Patch ``os.getuid()`` so that ceph-volume's decorators that ensure a user | |
40 | is root (or is sudoing to superuser) can continue as-is | |
41 | """ | |
42 | monkeypatch.setattr('os.getuid', lambda: 0) |