Merge "Fix wrong usage of rbd.list_snaps return value"
This commit is contained in:
commit
dd23857ade
@ -616,7 +616,7 @@ class CephBackupDriver(driver.BackupDriver):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
for snap in snaps:
|
for snap in snaps:
|
||||||
if snap.name == snap_name:
|
if snap['name'] == snap_name:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -19,6 +19,7 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import ddt
|
||||||
import mock
|
import mock
|
||||||
from os_brick.initiator import linuxrbd
|
from os_brick.initiator import linuxrbd
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
@ -102,6 +103,7 @@ def common_mocks(f):
|
|||||||
return _common_inner_inner1
|
return _common_inner_inner1
|
||||||
|
|
||||||
|
|
||||||
|
@ddt.ddt
|
||||||
class BackupCephTestCase(test.TestCase):
|
class BackupCephTestCase(test.TestCase):
|
||||||
"""Test case for ceph backup driver."""
|
"""Test case for ceph backup driver."""
|
||||||
|
|
||||||
@ -1151,6 +1153,19 @@ class BackupCephTestCase(test.TestCase):
|
|||||||
|
|
||||||
self.assertTrue(self.mock_rados.Object.return_value.read.called)
|
self.assertTrue(self.mock_rados.Object.return_value.read.called)
|
||||||
|
|
||||||
|
@ddt.data((None, False),
|
||||||
|
([{'name': 'test'}], False),
|
||||||
|
([{'name': 'test'}, {'name': 'fake'}], True))
|
||||||
|
@ddt.unpack
|
||||||
|
@common_mocks
|
||||||
|
def test__snap_exists(self, snapshots, snap_exist):
|
||||||
|
client = mock.Mock()
|
||||||
|
with mock.patch.object(self.service.rbd.Image(),
|
||||||
|
'list_snaps') as snaps:
|
||||||
|
snaps.return_value = snapshots
|
||||||
|
exist = self.service._snap_exists(None, 'fake', client)
|
||||||
|
self.assertEqual(snap_exist, exist)
|
||||||
|
|
||||||
|
|
||||||
def common_meta_backup_mocks(f):
|
def common_meta_backup_mocks(f):
|
||||||
"""Decorator to set mocks common to all metadata backup tests.
|
"""Decorator to set mocks common to all metadata backup tests.
|
||||||
|
Loading…
Reference in New Issue
Block a user