3 from ceph_volume import exceptions
4 from ceph_volume.util import arg_validators
8 '', 'lv_name', '/lv_name', 'lv_name/',
9 '/dev/lv_group/lv_name'
13 class TestLVPath(object):
16 self.validator = arg_validators.LVPath()
18 @pytest.mark.parametrize('path', invalid_lv_paths)
19 def test_no_slash_is_an_error(self, path):
20 with pytest.raises(argparse.ArgumentError):
23 def test_is_valid(self):
25 assert self.validator(path) == path
27 def test_abspath_is_valid(self):
29 assert self.validator(path) == path
32 class TestOSDPath(object):
35 self.validator = arg_validators.OSDPath()
37 def test_is_not_root(self):
38 with pytest.raises(exceptions.SuperUserError):
41 def test_path_is_not_a_directory(self, is_root, tmpfile, monkeypatch):
42 monkeypatch.setattr(arg_validators.disk, 'is_partition', lambda x: False)
43 validator = arg_validators.OSDPath()
44 with pytest.raises(argparse.ArgumentError):
47 def test_files_are_missing(self, is_root, tmpdir, monkeypatch):
49 monkeypatch.setattr(arg_validators.disk, 'is_partition', lambda x: False)
50 validator = arg_validators.OSDPath()
51 with pytest.raises(argparse.ArgumentError) as error:
53 assert 'Required file (ceph_fsid) was not found in OSD' in str(error)