]> git.proxmox.com Git - ceph.git/blame - ceph/src/ceph-volume/ceph_volume/tests/test_main.py
update sources to v12.2.4
[ceph.git] / ceph / src / ceph-volume / ceph_volume / tests / test_main.py
CommitLineData
d2e6a577
FG
1import os
2import pytest
3from ceph_volume import main
4
5
6class TestVolume(object):
7
8 def test_main_spits_help_with_no_arguments(self, capsys):
9 main.Volume(argv=[])
10 stdout, stderr = capsys.readouterr()
11 assert 'Log Path' in stdout
12
13 def test_warn_about_using_help_for_full_options(self, capsys):
14 main.Volume(argv=[])
15 stdout, stderr = capsys.readouterr()
16 assert 'See "ceph-volume --help" for full list' in stdout
17
18 def test_environ_vars_show_up(self, capsys):
19 os.environ['CEPH_CONF'] = '/opt/ceph.conf'
20 main.Volume(argv=[])
21 stdout, stderr = capsys.readouterr()
22 assert 'CEPH_CONF' in stdout
23 assert '/opt/ceph.conf' in stdout
24
25 def test_flags_are_parsed_with_help(self, capsys):
26 with pytest.raises(SystemExit):
27 main.Volume(argv=['ceph-volume', '--help'])
28 stdout, stderr = capsys.readouterr()
29 assert '--cluster' in stdout
30 assert '--log-path' in stdout
b32b8144
FG
31
32 def test_log_ignoring_missing_ceph_conf(self, caplog):
33 with pytest.raises(SystemExit) as error:
34 main.Volume(argv=['ceph-volume', '--cluster', 'barnacle', 'lvm', '--help'])
35 # make sure we aren't causing an actual error
36 assert error.value.code == 0
3a9019d9 37 log = caplog.records[1]
b32b8144
FG
38 assert log.message == 'ignoring inability to load ceph.conf'
39 assert log.levelname == 'ERROR'
3a9019d9
FG
40
41 def test_logs_current_command(self, caplog):
42 with pytest.raises(SystemExit) as error:
43 main.Volume(argv=['ceph-volume', '--cluster', 'barnacle', 'lvm', '--help'])
44 # make sure we aren't causing an actual error
45 assert error.value.code == 0
46 log = caplog.records[0]
47 assert log.message == 'Running command: ceph-volume --cluster barnacle lvm --help'
48 assert log.levelname == 'INFO'