From: Alfredo Deza Date: Mon, 6 Nov 2017 15:36:14 +0000 (-0500) Subject: ceph-volume tests.simple create etc_path scan tests X-Git-Tag: v13.0.1~256^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=90ebc4e1ffa7b3273787d708bb2c05180530b5d1;p=ceph.git ceph-volume tests.simple create etc_path scan tests Signed-off-by: Alfredo Deza --- diff --git a/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py b/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py index 56489f751c13..9ab47350bf01 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py +++ b/src/ceph-volume/ceph_volume/tests/devices/simple/test_scan.py @@ -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