From 90ebc4e1ffa7b3273787d708bb2c05180530b5d1 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Mon, 6 Nov 2017 10:36:14 -0500 Subject: [PATCH] ceph-volume tests.simple create etc_path scan tests Signed-off-by: Alfredo Deza --- .../tests/devices/simple/test_scan.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) 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 56489f751c1..9ab47350bf0 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 -- 2.39.5