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