]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests verify that INI comments can be inlined
authorAlfredo Deza <adeza@redhat.com>
Mon, 4 Dec 2017 13:21:29 +0000 (08:21 -0500)
committerAlfredo Deza <adeza@redhat.com>
Mon, 4 Dec 2017 13:25:58 +0000 (08:25 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/test_configuration.py

index 51ead952291fcd2d48c0f974a42aa4a5e7d92337..0009532c44efb23e6030462b00b720fd2fe1e1a2 100644 (file)
@@ -10,6 +10,10 @@ from ceph_volume import configuration, exceptions
 tabbed_conf = """
 [global]
             default = 0
+            other_h = 1 # comment
+            other_c = 1 ; comment
+            colon = ;
+            hash = #
 """
 
 
@@ -76,6 +80,20 @@ class TestLoad(object):
         result = configuration.load(conf_path)
         assert result.get('global', 'default') == '0'
 
+    def test_load_with_colon_comments(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', 'other_c') == '1'
+
+    def test_load_with_hash_comments(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', 'other_h') == '1'
+
     def test_path_does_not_exist(self):
         with pytest.raises(exceptions.ConfigurationError):
             conf = configuration.load('/path/does/not/exist/ceph.con')
@@ -89,3 +107,11 @@ class TestLoad(object):
             configuration.load(ceph_conf)
         stdout, stderr = capsys.readouterr()
         assert 'File contains no section headers' in stdout
+
+    @pytest.mark.parametrize('commented', ['colon','hash'])
+    def test_coment_as_a_value(self, tmpdir, commented):
+        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', commented) == ''