Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / 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         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
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
37         log = caplog.records[0]
38         assert log.message == 'ignoring inability to load ceph.conf'
39         assert log.levelname == 'ERROR'