mirror of
https://github.com/ceph/ceph
synced 2025-02-21 18:17:42 +00:00
ceph-disk/tests: mock get_fsid
should offer a valid fsid for the ceph-disk under testing. Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
27e06ffa4c
commit
cc49d1d2b9
@ -45,7 +45,8 @@ class Base(object):
|
||||
|
||||
class TestPrepare(Base):
|
||||
|
||||
def test_init_filestore_dir(self):
|
||||
@mock.patch('ceph_disk.main.get_fsid')
|
||||
def test_init_filestore_dir(self, m_get_fsid):
|
||||
parser = argparse.ArgumentParser('ceph-disk')
|
||||
subparsers = parser.add_subparsers()
|
||||
main.Prepare.set_subparser(subparsers)
|
||||
@ -60,9 +61,11 @@ class TestPrepare(Base):
|
||||
|
||||
def set_type(self):
|
||||
self.type = self.FILE
|
||||
m_get_fsid.return_value = '571bb920-6d85-44d7-9eca-1bc114d1cd75'
|
||||
with mock.patch.multiple(main.PrepareData,
|
||||
set_type=set_type):
|
||||
prepare = main.Prepare.factory(args)
|
||||
prepare = main.Prepare.factory(args)
|
||||
assert isinstance(prepare.data, main.PrepareFilestoreData)
|
||||
assert prepare.data.is_file()
|
||||
assert isinstance(prepare.journal, main.PrepareJournal)
|
||||
@ -73,7 +76,11 @@ class TestPrepare(Base):
|
||||
|
||||
@mock.patch('stat.S_ISBLK')
|
||||
@mock.patch('ceph_disk.main.is_partition')
|
||||
def test_init_filestore_dev(self, m_is_partition, m_s_isblk):
|
||||
@mock.patch('ceph_disk.main.get_fsid')
|
||||
def test_init_filestore_dev(self,
|
||||
m_get_fsid,
|
||||
m_is_partition,
|
||||
m_s_isblk):
|
||||
m_s_isblk.return_value = True
|
||||
|
||||
parser = argparse.ArgumentParser('ceph-disk')
|
||||
@ -88,13 +95,15 @@ class TestPrepare(Base):
|
||||
data,
|
||||
'--filestore',
|
||||
])
|
||||
m_get_fsid.return_value = '571bb920-6d85-44d7-9eca-1bc114d1cd75'
|
||||
prepare = main.Prepare.factory(args)
|
||||
assert isinstance(prepare.data, main.PrepareData)
|
||||
assert prepare.data.is_device()
|
||||
assert isinstance(prepare.journal, main.PrepareJournal)
|
||||
assert prepare.journal.is_device()
|
||||
|
||||
def test_init_default_dir(self):
|
||||
@mock.patch('ceph_disk.main.get_fsid')
|
||||
def test_init_default_dir(self, m_get_fsid):
|
||||
parser = argparse.ArgumentParser('ceph-disk')
|
||||
subparsers = parser.add_subparsers()
|
||||
main.Prepare.set_subparser(subparsers)
|
||||
@ -108,6 +117,7 @@ class TestPrepare(Base):
|
||||
|
||||
def set_type(self):
|
||||
self.type = self.FILE
|
||||
m_get_fsid.return_value = '571bb920-6d85-44d7-9eca-1bc114d1cd75'
|
||||
with mock.patch.multiple(main.PrepareData,
|
||||
set_type=set_type):
|
||||
prepare = main.Prepare.factory(args)
|
||||
@ -376,7 +386,8 @@ class TestCryptHelpers(Base):
|
||||
|
||||
class TestPrepareData(Base):
|
||||
|
||||
def test_set_variables(self):
|
||||
@mock.patch('ceph_disk.main.get_fsid')
|
||||
def test_set_variables(self, m_get_fsid):
|
||||
parser = argparse.ArgumentParser('ceph-disk')
|
||||
subparsers = parser.add_subparsers()
|
||||
main.Prepare.set_subparser(subparsers)
|
||||
@ -393,6 +404,7 @@ class TestPrepareData(Base):
|
||||
|
||||
def set_type(self):
|
||||
self.type = self.FILE
|
||||
m_get_fsid.return_value = cluster_uuid
|
||||
with mock.patch.multiple(main.PrepareData,
|
||||
set_type=set_type):
|
||||
data = main.PrepareData(args)
|
||||
|
Loading…
Reference in New Issue
Block a user