]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-volume tests.simple create etc_path scan tests
authorAlfredo Deza <adeza@redhat.com>
Mon, 6 Nov 2017 15:36:14 +0000 (10:36 -0500)
committerAlfredo Deza <adeza@redhat.com>
Mon, 6 Nov 2017 16:04:00 +0000 (11:04 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py

index 56489f751c136ec5c89df21d1a2e8e319f8ed218..9ab47350bf014cb9d4bd2e1cdb72214295480439 100644 (file)
@@ -1,3 +1,5 @@
+import os
+import pytest
 from ceph_volume.devices.simple import scan
 
 
@@ -17,3 +19,26 @@ class TestGetContentst(object):
         magic_file = tmpfile(contents='first\n')
         scanner = scan.Scan([])
         assert scanner.get_contents(magic_file) == 'first'
+
+
+class TestEtcPath(object):
+
+    def test_directory_is_valid(self, tmpdir):
+        path = str(tmpdir)
+        scanner = scan.Scan([])
+        scanner._etc_path = path
+        assert scanner.etc_path == path
+
+    def test_directory_does_not_exist_gets_created(self, tmpdir):
+        path = os.path.join(str(tmpdir), 'subdir')
+        scanner = scan.Scan([])
+        scanner._etc_path = path
+        assert scanner.etc_path == path
+        assert os.path.isdir(path)
+
+    def test_complains_when_file(self, tmpfile):
+        path = tmpfile()
+        scanner = scan.Scan([])
+        scanner._etc_path = path
+        with pytest.raises(RuntimeError):
+            scanner.etc_path