From: Alfredo Deza Date: Mon, 13 Aug 2018 19:42:26 +0000 (-0400) Subject: ceph-volume tests.util ensure dmcrypt_close will skip non-existent paths X-Git-Tag: v14.0.1~520^2~3^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7a5ee22437a05fc809bffde97c8e3401f7ba564d;p=ceph.git ceph-volume tests.util ensure dmcrypt_close will skip non-existent paths Signed-off-by: Alfredo Deza --- diff --git a/src/ceph-volume/ceph_volume/tests/util/test_encryption.py b/src/ceph-volume/ceph_volume/tests/util/test_encryption.py index 3d84e55394163..8cca42689b41e 100644 --- a/src/ceph-volume/ceph_volume/tests/util/test_encryption.py +++ b/src/ceph-volume/ceph_volume/tests/util/test_encryption.py @@ -17,3 +17,19 @@ class TestStatus(object): out = ['some line here', ' '] stub_call((out, '', 0)) assert encryption.status('/dev/sdc1') == {} + + +class TestDmcryptClose(object): + + def test_mapper_exists(self, fake_run, tmpfile): + file_name = tmpfile(name='mapper-device') + encryption.dmcrypt_close(file_name) + arguments = fake_run.calls[0]['args'][0] + assert arguments[0] == 'cryptsetup' + assert arguments[1] == 'remove' + assert arguments[2].startswith('/') + + def test_mapper_does_not_exist(self, fake_run): + file_name = '/path/does/not/exist' + encryption.dmcrypt_close(file_name) + assert fake_run.calls == []