]>
Commit | Line | Data |
---|---|---|
d2e6a577 FG |
1 | import pytest |
2 | from ceph_volume.devices import lvm | |
3 | ||
4 | ||
5 | class TestLVM(object): | |
6 | ||
7 | def test_main_spits_help_with_no_arguments(self, capsys): | |
8 | lvm.main.LVM([]).main() | |
9 | stdout, stderr = capsys.readouterr() | |
10 | assert 'Use LVM and LVM-based technologies like dmcache to deploy' in stdout | |
11 | ||
12 | def test_main_shows_activate_subcommands(self, capsys): | |
13 | lvm.main.LVM([]).main() | |
14 | stdout, stderr = capsys.readouterr() | |
15 | assert 'activate ' in stdout | |
16 | assert 'Discover and mount' in stdout | |
17 | ||
18 | def test_main_shows_prepare_subcommands(self, capsys): | |
19 | lvm.main.LVM([]).main() | |
20 | stdout, stderr = capsys.readouterr() | |
21 | assert 'prepare ' in stdout | |
22 | assert 'Format an LVM device' in stdout | |
23 | ||
24 | ||
25 | class TestPrepare(object): | |
26 | ||
27 | def test_main_spits_help_with_no_arguments(self, capsys): | |
28 | lvm.prepare.Prepare([]).main() | |
29 | stdout, stderr = capsys.readouterr() | |
30 | assert 'Prepare an OSD by assigning an ID and FSID' in stdout | |
31 | ||
32 | def test_main_shows_full_help(self, capsys): | |
33 | with pytest.raises(SystemExit): | |
34 | lvm.prepare.Prepare(argv=['--help']).main() | |
35 | stdout, stderr = capsys.readouterr() | |
3efd9988 FG |
36 | assert 'Use the filestore objectstore' in stdout |
37 | assert 'Use the bluestore objectstore' in stdout | |
38 | assert 'A physical device or logical' in stdout | |
d2e6a577 FG |
39 | |
40 | ||
b5b8bbf5 FG |
41 | class TestGetJournalLV(object): |
42 | ||
43 | @pytest.mark.parametrize('arg', ['', '///', None, '/dev/sda1']) | |
44 | def test_no_journal_on_invalid_path(self, monkeypatch, arg): | |
45 | monkeypatch.setattr(lvm.prepare.api, 'get_lv', lambda **kw: False) | |
46 | prepare = lvm.prepare.Prepare([]) | |
3efd9988 | 47 | assert prepare.get_lv(arg) is None |
b5b8bbf5 FG |
48 | |
49 | def test_no_journal_lv_found(self, monkeypatch): | |
50 | # patch it with 0 so we know we are getting to get_lv | |
51 | monkeypatch.setattr(lvm.prepare.api, 'get_lv', lambda **kw: 0) | |
52 | prepare = lvm.prepare.Prepare([]) | |
3efd9988 | 53 | assert prepare.get_lv('vg/lv') == 0 |
b5b8bbf5 FG |
54 | |
55 | ||
d2e6a577 FG |
56 | class TestActivate(object): |
57 | ||
58 | def test_main_spits_help_with_no_arguments(self, capsys): | |
59 | lvm.activate.Activate([]).main() | |
60 | stdout, stderr = capsys.readouterr() | |
61 | assert 'Activate OSDs by discovering them with' in stdout | |
62 | ||
63 | def test_main_shows_full_help(self, capsys): | |
64 | with pytest.raises(SystemExit): | |
65 | lvm.activate.Activate(argv=['--help']).main() | |
66 | stdout, stderr = capsys.readouterr() | |
67 | assert 'optional arguments' in stdout | |
68 | assert 'positional arguments' in stdout | |
69 |