]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests create tests for the new arg validator
authorAlfredo Deza <adeza@redhat.com>
Wed, 23 Aug 2017 17:29:15 +0000 (13:29 -0400)
committerAlfredo Deza <adeza@redhat.com>
Wed, 23 Aug 2017 22:19:50 +0000 (18:19 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit d5eb9640aa4b20eabc9b5fdd07559082346478c6)

src/ceph-volume/ceph_volume/tests/util/test_arg_validators.py [new file with mode: 0644]

diff --git a/src/ceph-volume/ceph_volume/tests/util/test_arg_validators.py b/src/ceph-volume/ceph_volume/tests/util/test_arg_validators.py
new file mode 100644 (file)
index 0000000..9174691
--- /dev/null
@@ -0,0 +1,24 @@
+import pytest
+import argparse
+from ceph_volume.util import arg_validators
+
+
+invalid_lv_paths = [
+    '', 'lv_name', '///', '/lv_name', 'lv_name/',
+    '/dev/lv_group/lv_name'
+]
+
+
+class TestLVPath(object):
+
+    def setup(self):
+        self.validator = arg_validators.LVPath()
+
+    @pytest.mark.parametrize('path', invalid_lv_paths)
+    def test_no_slash_is_an_error(self, path):
+        with pytest.raises(argparse.ArgumentError):
+            self.validator(path)
+
+    def test_is_valid(self):
+        path = 'vg/lv'
+        assert self.validator(path) == path