def test_get_non_existing_list(self):
cfg = configuration.Conf()
+ cfg.is_valid = lambda: True
cfg.readfp(self.conf_file)
assert cfg.get_list('global', 'key') == []
def test_get_non_existing_list_get_default(self):
cfg = configuration.Conf()
+ cfg.is_valid = lambda: True
cfg.readfp(self.conf_file)
assert cfg.get_list('global', 'key', ['a']) == ['a']
def test_get_rid_of_comments(self):
cfg = configuration.Conf()
+ cfg.is_valid = lambda: True
conf_file = StringIO(dedent("""
[foo]
default = 0 # this is a comment
def test_gets_split_on_commas(self):
cfg = configuration.Conf()
+ cfg.is_valid = lambda: True
conf_file = StringIO(dedent("""
[foo]
default = 0,1,2,3 # this is a comment
def test_spaces_and_tabs_are_ignored(self):
cfg = configuration.Conf()
+ cfg.is_valid = lambda: True
conf_file = StringIO(dedent("""
[foo]
default = 0, 1, 2 ,3 # this is a comment
def test_path_does_not_exist(self):
with pytest.raises(exceptions.ConfigurationError):
- configuration.load('/path/does/not/exist/ceph.con')
+ conf = configuration.load('/path/does/not/exist/ceph.con')
+ conf.is_valid()
def test_unable_to_read_configuration(self, tmpdir, capsys):
ceph_conf = os.path.join(str(tmpdir), 'ceph.conf')