]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/ceph-volume/ceph_volume/tests/devices/lvm/test_prepare.py
import ceph quincy 17.2.1
[ceph.git] / ceph / src / ceph-volume / ceph_volume / tests / devices / lvm / test_prepare.py
index fcbc276f0de1b6f4b3d25cc0f11a865881cb2da4..9f0a5e0bbc2239816cc9f5d43182dd3843468d8a 100644 (file)
@@ -1,7 +1,7 @@
 import pytest
 from ceph_volume.devices import lvm
 from ceph_volume.api import lvm as api
-from mock.mock import patch, Mock
+from mock.mock import patch, Mock, MagicMock
 
 
 class TestLVM(object):
@@ -66,7 +66,9 @@ class TestPrepare(object):
         assert 'Use the bluestore objectstore' in stdout
         assert 'A physical device or logical' in stdout
 
-    def test_excludes_filestore_bluestore_flags(self, capsys, device_info):
+
+    @patch('ceph_volume.util.disk.has_bluestore_label', return_value=False)
+    def test_excludes_filestore_bluestore_flags(self, m_has_bs_label, fake_call, capsys, device_info):
         device_info()
         with pytest.raises(SystemExit):
             lvm.prepare.Prepare(argv=['--data', '/dev/sdfoo', '--filestore', '--bluestore']).main()
@@ -74,7 +76,9 @@ class TestPrepare(object):
         expected = 'Cannot use --filestore (filestore) with --bluestore (bluestore)'
         assert expected in stderr
 
-    def test_excludes_other_filestore_bluestore_flags(self, capsys, device_info):
+
+    @patch('ceph_volume.util.disk.has_bluestore_label', return_value=False)
+    def test_excludes_other_filestore_bluestore_flags(self, m_has_bs_label, fake_call, capsys, device_info):
         device_info()
         with pytest.raises(SystemExit):
             lvm.prepare.Prepare(argv=[
@@ -85,7 +89,8 @@ class TestPrepare(object):
         expected = 'Cannot use --bluestore (bluestore) with --journal (filestore)'
         assert expected in stderr
 
-    def test_excludes_block_and_journal_flags(self, capsys, device_info):
+    @patch('ceph_volume.util.disk.has_bluestore_label', return_value=False)
+    def test_excludes_block_and_journal_flags(self, m_has_bs_label, fake_call, capsys, device_info):
         device_info()
         with pytest.raises(SystemExit):
             lvm.prepare.Prepare(argv=[
@@ -96,9 +101,15 @@ class TestPrepare(object):
         expected = 'Cannot use --block.db (bluestore) with --journal (filestore)'
         assert expected in stderr
 
-    def test_journal_is_required_with_filestore(self, is_root, monkeypatch, device_info):
+    @patch('ceph_volume.util.arg_validators.Device')
+    @patch('ceph_volume.util.disk.has_bluestore_label', return_value=False)
+    def test_journal_is_required_with_filestore(self, m_has_bs_label, m_device, is_root, monkeypatch, device_info):
+        m_device.return_value = MagicMock(exists=True,
+                                          has_fs=False,
+                                          used_by_ceph=False,
+                                          has_partitions=False,
+                                          has_gpt_headers=False)
         monkeypatch.setattr("os.path.exists", lambda path: True)
-        device_info()
         with pytest.raises(SystemExit) as error:
             lvm.prepare.Prepare(argv=['--filestore', '--data', '/dev/sdfoo']).main()
         expected = '--journal is required when using --filestore'