From ec7f8a27b8c51e1e1d02a2a13d9219bbb1a58c26 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 30 Nov 2017 08:58:37 -0500 Subject: [PATCH] ceph-volume test leading whitespace is handled in configurations Signed-off-by: Alfredo Deza --- .../ceph_volume/tests/test_configuration.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ceph-volume/ceph_volume/tests/test_configuration.py b/src/ceph-volume/ceph_volume/tests/test_configuration.py index 5ef7fae47f8b..51ead952291f 100644 --- a/src/ceph-volume/ceph_volume/tests/test_configuration.py +++ b/src/ceph-volume/ceph_volume/tests/test_configuration.py @@ -7,6 +7,11 @@ from textwrap import dedent import pytest from ceph_volume import configuration, exceptions +tabbed_conf = """ +[global] + default = 0 +""" + class TestConf(object): @@ -64,6 +69,13 @@ class TestConf(object): class TestLoad(object): + def test_load_from_path(self, tmpdir): + conf_path = os.path.join(str(tmpdir), 'ceph.conf') + with open(conf_path, 'w') as conf: + conf.write(tabbed_conf) + result = configuration.load(conf_path) + assert result.get('global', 'default') == '0' + def test_path_does_not_exist(self): with pytest.raises(exceptions.ConfigurationError): conf = configuration.load('/path/does/not/exist/ceph.con') @@ -73,7 +85,7 @@ class TestLoad(object): ceph_conf = os.path.join(str(tmpdir), 'ceph.conf') with open(ceph_conf, 'w') as config: config.write(']broken] config\n[[') - configuration.load(ceph_conf) + with pytest.raises(RuntimeError): + configuration.load(ceph_conf) stdout, stderr = capsys.readouterr() - assert 'Unable to read configuration file' in stdout assert 'File contains no section headers' in stdout -- 2.47.3