tests: replace mox by mox3, clean out mox usage
This patch replaces mox3 by mox, so we can drop mox from requirements and bring Python 3 compatibility. It also clear some mox usage and use the fixture brought by oslotest. Change-Id: Ia242425815b09e1e67d33702f1e5dbe6bcd599fd
This commit is contained in:
parent
844b4fd4ea
commit
8e6ab7a555
@ -28,7 +28,6 @@ import uuid
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
import mox
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as config_fixture
|
||||
@ -36,7 +35,7 @@ from oslo_log import log
|
||||
from oslo_messaging import conffixture as messaging_conffixture
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import timeutils
|
||||
import stubout
|
||||
from oslotest import moxstubout
|
||||
import testtools
|
||||
|
||||
from cinder.common import config # noqa Need to register global_opts
|
||||
@ -196,13 +195,10 @@ class TestCase(testtools.TestCase):
|
||||
|
||||
# emulate some of the mox stuff, we can't use the metaclass
|
||||
# because it screws with our generators
|
||||
self.mox = mox.Mox()
|
||||
self.stubs = stubout.StubOutForTesting()
|
||||
mox_fixture = self.useFixture(moxstubout.MoxStubout())
|
||||
self.mox = mox_fixture.mox
|
||||
self.stubs = mox_fixture.stubs
|
||||
self.addCleanup(CONF.reset)
|
||||
self.addCleanup(self.mox.UnsetStubs)
|
||||
self.addCleanup(self.stubs.UnsetAll)
|
||||
self.addCleanup(self.stubs.SmartUnsetAll)
|
||||
self.addCleanup(self.mox.VerifyAll)
|
||||
self.addCleanup(self._common_cleanup)
|
||||
self.injected = []
|
||||
self._services = []
|
||||
|
@ -12,8 +12,7 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_log import log as logging
|
||||
|
||||
@ -33,7 +32,6 @@ def create_configuration():
|
||||
|
||||
class BrickLvmTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
self._mox = mox.Mox()
|
||||
self.configuration = mox.MockObject(conf.Configuration)
|
||||
self.configuration.volume_group_name = 'fake-vg'
|
||||
super(BrickLvmTestCase, self).setUp()
|
||||
@ -151,9 +149,9 @@ class BrickLvmTestCase(test.TestCase):
|
||||
self.assertEqual(self.vg.create_lv_snapshot('snapshot-1', 'fake-1'),
|
||||
None)
|
||||
|
||||
self._mox.StubOutWithMock(self.vg, 'get_volume')
|
||||
self.mox.StubOutWithMock(self.vg, 'get_volume')
|
||||
self.vg.get_volume('fake-non-existent').AndReturn(None)
|
||||
self._mox.ReplayAll()
|
||||
self.mox.ReplayAll()
|
||||
try:
|
||||
self.vg.create_lv_snapshot('snapshot-1', 'fake-non-existent')
|
||||
except exception.VolumeDeviceNotFound as e:
|
||||
@ -329,18 +327,18 @@ class BrickLvmTestCase(test.TestCase):
|
||||
self.assertFalse(self.vg.lv_has_snapshot('test-volumes'))
|
||||
|
||||
def test_activate_lv(self):
|
||||
self._mox.StubOutWithMock(self.vg, '_execute')
|
||||
self.mox.StubOutWithMock(self.vg, '_execute')
|
||||
self.vg._supports_lvchange_ignoreskipactivation = True
|
||||
|
||||
self.vg._execute('lvchange', '-a', 'y', '--yes', '-K',
|
||||
'fake-vg/my-lv',
|
||||
root_helper='sudo', run_as_root=True)
|
||||
|
||||
self._mox.ReplayAll()
|
||||
self.mox.ReplayAll()
|
||||
|
||||
self.vg.activate_lv('my-lv')
|
||||
|
||||
self._mox.VerifyAll()
|
||||
self.mox.VerifyAll()
|
||||
|
||||
def test_get_mirrored_available_capacity(self):
|
||||
self.assertEqual(self.vg.vg_mirror_free_space(1), 2.0)
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from oslo_log import log as logging
|
||||
|
||||
from cinder.brick import exception
|
||||
@ -33,10 +32,8 @@ class BrickRemoteFsTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(BrickRemoteFsTestCase, self).setUp()
|
||||
self._mox = mox.Mox()
|
||||
self._nfsclient = remotefs.RemoteFsClient(
|
||||
'nfs', 'sudo', nfs_mount_point_base=self.TEST_MNT_BASE)
|
||||
self.addCleanup(self._mox.UnsetStubs)
|
||||
|
||||
def test_get_hash_str(self):
|
||||
"""_get_hash_str should calculation correct value."""
|
||||
@ -49,7 +46,7 @@ class BrickRemoteFsTestCase(test.TestCase):
|
||||
self.assertEqual(mnt_point, self.TEST_MNT_POINT)
|
||||
|
||||
def test_mount_nfs_should_mount_correctly(self):
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
client = self._nfsclient
|
||||
|
||||
mox.StubOutWithMock(client, '_execute')
|
||||
@ -143,7 +140,7 @@ class BrickRemoteFsTestCase(test.TestCase):
|
||||
self.TEST_EXPORT)
|
||||
|
||||
def test_mount_nfs_should_not_remount(self):
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
client = self._nfsclient
|
||||
|
||||
line = "%s on %s type nfs (rw)\n" % (self.TEST_EXPORT,
|
||||
|
@ -22,7 +22,7 @@ Self test for Hitachi Unified Storage (HUS) platform.
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
|
||||
from cinder import test
|
||||
from cinder.volume import configuration as conf
|
||||
@ -174,14 +174,12 @@ class HUSiSCSIDriverTest(test.TestCase):
|
||||
SimulatedHusBackend.alloc_lun = []
|
||||
SimulatedHusBackend.connections = []
|
||||
SimulatedHusBackend.out = ''
|
||||
self.mox = mox.Mox()
|
||||
self.mox.StubOutWithMock(hds, 'factory_bend')
|
||||
hds.factory_bend().AndReturn(SimulatedHusBackend())
|
||||
self.mox.ReplayAll()
|
||||
self.configuration = mox.MockObject(conf.Configuration)
|
||||
self.configuration.hds_cinder_config_file = self.config_file
|
||||
self.driver = hds.HUSDriver(configuration=self.configuration)
|
||||
self.addCleanup(self.mox.UnsetStubs)
|
||||
|
||||
def test_get_volume_stats(self):
|
||||
stats = self.driver.get_volume_stats(True)
|
||||
@ -273,6 +271,8 @@ class HUSiSCSIDriverTest(test.TestCase):
|
||||
connector['host'] = 'dut_1.lab.hds.com'
|
||||
vol = self.test_create_volume()
|
||||
self.mox.StubOutWithMock(self.driver, '_update_vol_location')
|
||||
self.driver._update_vol_location(vol['id'], mox.IgnoreArg())
|
||||
self.mox.ReplayAll()
|
||||
conn = self.driver.initialize_connection(vol, connector)
|
||||
self.assertIn('hitachi', conn['data']['target_iqn'])
|
||||
self.assertIn('3260', conn['data']['target_portal'])
|
||||
@ -287,8 +287,19 @@ class HUSiSCSIDriverTest(test.TestCase):
|
||||
because an error/exception return will only jeopardize the
|
||||
connection tear down at a host.
|
||||
"""
|
||||
(vol, conn) = self.test_initialize_connection()
|
||||
connector = {}
|
||||
connector['initiator'] = 'iqn.1993-08.org.debian:01:11f90746eb2'
|
||||
connector['host'] = 'dut_1.lab.hds.com'
|
||||
vol = self.test_create_volume()
|
||||
self.mox.StubOutWithMock(self.driver, '_update_vol_location')
|
||||
self.driver._update_vol_location(vol['id'], mox.IgnoreArg())
|
||||
self.driver._update_vol_location(vol['id'], mox.IgnoreArg())
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
conn = self.driver.initialize_connection(vol, connector)
|
||||
vol['provider_location'] = conn['data']['provider_location']
|
||||
num_conn_before = len(SimulatedHusBackend.connections)
|
||||
self.driver.terminate_connection(vol, conn)
|
||||
self.driver.terminate_connection(vol, connector)
|
||||
num_conn_after = len(SimulatedHusBackend.connections)
|
||||
self.assertGreater(num_conn_before, num_conn_after)
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
import copy
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo_config import cfg
|
||||
|
||||
from cinder import context
|
||||
|
@ -21,7 +21,7 @@ import unittest
|
||||
|
||||
from lxml import etree
|
||||
import mock
|
||||
import mox as mox_lib
|
||||
from mox3 import mox as mox_lib
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
|
@ -19,7 +19,7 @@ import copy
|
||||
import httplib
|
||||
|
||||
from lxml import etree
|
||||
import mox
|
||||
from mox3 import mox
|
||||
import six
|
||||
|
||||
from cinder import exception
|
||||
|
@ -19,8 +19,8 @@ import os
|
||||
import testtools
|
||||
|
||||
import mock
|
||||
import mox as mox_lib
|
||||
from mox import stubout
|
||||
from mox3 import mox as mox_lib
|
||||
from mox3.mox import stubout
|
||||
from oslo_utils import units
|
||||
|
||||
from cinder import exception
|
||||
@ -49,17 +49,15 @@ class RemoteFsDriverTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(RemoteFsDriverTestCase, self).setUp()
|
||||
self._driver = remotefs.RemoteFSDriver()
|
||||
self._mox = mox_lib.Mox()
|
||||
self.configuration = mox_lib.MockObject(conf.Configuration)
|
||||
self.configuration.append_config_values(mox_lib.IgnoreArg())
|
||||
self.configuration.nas_secure_file_permissions = 'false'
|
||||
self.configuration.nas_secure_file_operations = 'false'
|
||||
self._driver = remotefs.RemoteFSDriver(
|
||||
configuration=self.configuration)
|
||||
self.addCleanup(self._mox.UnsetStubs)
|
||||
|
||||
def test_create_sparsed_file(self):
|
||||
(mox, drv) = self._mox, self._driver
|
||||
(mox, drv) = self.mox, self._driver
|
||||
|
||||
mox.StubOutWithMock(drv, '_execute')
|
||||
drv._execute('truncate', '-s', '1G', '/path', run_as_root=True).\
|
||||
@ -72,7 +70,7 @@ class RemoteFsDriverTestCase(test.TestCase):
|
||||
mox.VerifyAll()
|
||||
|
||||
def test_create_regular_file(self):
|
||||
(mox, drv) = self._mox, self._driver
|
||||
(mox, drv) = self.mox, self._driver
|
||||
|
||||
mox.StubOutWithMock(drv, '_execute')
|
||||
drv._execute('dd', 'if=/dev/zero', 'of=/path', 'bs=1M', 'count=1024',
|
||||
@ -85,7 +83,7 @@ class RemoteFsDriverTestCase(test.TestCase):
|
||||
mox.VerifyAll()
|
||||
|
||||
def test_create_qcow2_file(self):
|
||||
(mox, drv) = self._mox, self._driver
|
||||
(mox, drv) = self.mox, self._driver
|
||||
|
||||
file_size = 1
|
||||
|
||||
@ -101,7 +99,7 @@ class RemoteFsDriverTestCase(test.TestCase):
|
||||
mox.VerifyAll()
|
||||
|
||||
def test_set_rw_permissions_for_all(self):
|
||||
(mox, drv) = self._mox, self._driver
|
||||
(mox, drv) = self.mox, self._driver
|
||||
|
||||
mox.StubOutWithMock(drv, '_execute')
|
||||
drv._execute('chmod', 'ugo+rw', '/path', run_as_root=True)
|
||||
@ -356,7 +354,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NfsDriverTestCase, self).setUp()
|
||||
self._mox = mox_lib.Mox()
|
||||
self.mox = mox_lib.Mox()
|
||||
self.stubs = stubout.StubOutForTesting()
|
||||
self.configuration = mox_lib.MockObject(conf.Configuration)
|
||||
self.configuration.append_config_values(mox_lib.IgnoreArg())
|
||||
@ -377,7 +375,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
self._driver = nfs.NfsDriver(configuration=self.configuration)
|
||||
self._driver.shares = {}
|
||||
self.addCleanup(self.stubs.UnsetAll)
|
||||
self.addCleanup(self._mox.UnsetStubs)
|
||||
self.addCleanup(self.mox.UnsetStubs)
|
||||
|
||||
def stub_out_not_replaying(self, obj, attr_name):
|
||||
attr_to_replace = getattr(obj, attr_name)
|
||||
@ -399,7 +397,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def test_copy_image_to_volume(self):
|
||||
"""resize_image common case usage."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
TEST_IMG_SOURCE = 'foo.img'
|
||||
@ -460,7 +458,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def test_get_capacity_info(self):
|
||||
"""_get_capacity_info should calculate correct value."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
stat_total_size = 2620544
|
||||
@ -493,7 +491,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def test_get_capacity_info_for_share_and_mount_point_with_spaces(self):
|
||||
"""_get_capacity_info should calculate correct value."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
stat_total_size = 2620544
|
||||
@ -525,7 +523,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
mox.VerifyAll()
|
||||
|
||||
def test_load_shares_config(self):
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
drv.configuration.nfs_shares_config = self.TEST_SHARES_CONFIG_FILE
|
||||
@ -554,7 +552,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
mox.VerifyAll()
|
||||
|
||||
def test_load_shares_config_nas_opts(self):
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
mox.StubOutWithMock(drv, '_read_config_file') # ensure not called
|
||||
@ -574,7 +572,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def test_ensure_shares_mounted_should_save_mounting_successfully(self):
|
||||
"""_ensure_shares_mounted should save share if mounted with success."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
mox.StubOutWithMock(drv, '_read_config_file')
|
||||
@ -632,7 +630,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def test_find_share(self):
|
||||
"""_find_share simple use case."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
drv._mounted_shares = [self.TEST_NFS_EXPORT1, self.TEST_NFS_EXPORT2]
|
||||
@ -660,7 +658,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def test_find_share_should_throw_error_if_there_is_no_enough_place(self):
|
||||
"""_find_share should throw error if there is no share to host vol."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
drv._mounted_shares = [self.TEST_NFS_EXPORT1, self.TEST_NFS_EXPORT2]
|
||||
@ -688,7 +686,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
return volume
|
||||
|
||||
def test_create_sparsed_volume(self):
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
volume = self._simple_volume()
|
||||
|
||||
@ -707,7 +705,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
mox.VerifyAll()
|
||||
|
||||
def test_create_nonsparsed_volume(self):
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
self.configuration.nfs_sparsed_volumes = False
|
||||
volume = self._simple_volume()
|
||||
@ -728,7 +726,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def test_create_volume_should_ensure_nfs_mounted(self):
|
||||
"""create_volume ensures shares provided in config are mounted."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
self.stub_out_not_replaying(nfs, 'LOG')
|
||||
@ -748,7 +746,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def test_create_volume_should_return_provider_location(self):
|
||||
"""create_volume should return provider_location with found share."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
self.stub_out_not_replaying(nfs, 'LOG')
|
||||
@ -769,7 +767,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def test_delete_volume(self):
|
||||
"""delete_volume simple test case."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
self.stub_out_not_replaying(drv, '_ensure_share_mounted')
|
||||
@ -792,7 +790,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def test_delete_should_ensure_share_mounted(self):
|
||||
"""delete_volume should ensure that corresponding share is mounted."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
self.stub_out_not_replaying(drv, '_execute')
|
||||
@ -828,7 +826,7 @@ class NfsDriverTestCase(test.TestCase):
|
||||
|
||||
def test_get_volume_stats(self):
|
||||
"""get_volume_stats must fill the correct values."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
drv = self._driver
|
||||
|
||||
drv._mounted_shares = [self.TEST_NFS_EXPORT1, self.TEST_NFS_EXPORT2]
|
||||
|
@ -21,7 +21,8 @@ import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
import mox as mox_lib
|
||||
import mock
|
||||
from mox3 import mox as mox_lib
|
||||
from oslo_utils import units
|
||||
|
||||
from cinder import context
|
||||
@ -133,7 +134,6 @@ class ScalityDriverTestCase(test.TestCase):
|
||||
self.TEST_VOLDIR,
|
||||
self.TEST_CLONENAME)
|
||||
|
||||
self._mox = mox_lib.Mox()
|
||||
self.configuration = mox_lib.MockObject(conf.Configuration)
|
||||
self._configure_driver()
|
||||
super(ScalityDriverTestCase, self).setUp()
|
||||
@ -193,7 +193,7 @@ class ScalityDriverTestCase(test.TestCase):
|
||||
|
||||
def test_create_snapshot(self):
|
||||
"""Expected behaviour for create_snapshot."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
|
||||
vol_size = self._driver._size_bytes(self.TEST_VOLSIZE)
|
||||
|
||||
@ -206,12 +206,9 @@ class ScalityDriverTestCase(test.TestCase):
|
||||
|
||||
self._driver.create_snapshot(self.TEST_SNAPSHOT)
|
||||
|
||||
mox.UnsetStubs()
|
||||
mox.VerifyAll()
|
||||
|
||||
def test_delete_snapshot(self):
|
||||
"""Expected behaviour for delete_snapshot."""
|
||||
mox = self._mox
|
||||
mox = self.mox
|
||||
|
||||
mox.StubOutWithMock(os, 'remove')
|
||||
os.remove(self.TEST_SNAPPATH)
|
||||
@ -220,9 +217,6 @@ class ScalityDriverTestCase(test.TestCase):
|
||||
|
||||
self._driver.delete_snapshot(self.TEST_SNAPSHOT)
|
||||
|
||||
mox.UnsetStubs()
|
||||
mox.VerifyAll()
|
||||
|
||||
def test_initialize_connection(self):
|
||||
"""Expected behaviour for initialize_connection."""
|
||||
ret = self._driver.initialize_connection(self.TEST_VOLUME, None)
|
||||
@ -290,7 +284,8 @@ class ScalityDriverTestCase(test.TestCase):
|
||||
self._driver.extend_volume(self.TEST_VOLUME, self.TEST_NEWSIZE)
|
||||
|
||||
def test_backup_volume(self):
|
||||
self.mox.StubOutWithMock(self._driver, 'db')
|
||||
self.mox = mox_lib.Mox()
|
||||
self._driver.db = self.mox.CreateMockAnything()
|
||||
self.mox.StubOutWithMock(self._driver.db, 'volume_get')
|
||||
|
||||
volume = {'id': '2', 'name': self.TEST_VOLNAME}
|
||||
@ -302,45 +297,37 @@ class ScalityDriverTestCase(test.TestCase):
|
||||
image_utils.qemu_img_info(self.TEST_VOLPATH).AndReturn(info)
|
||||
|
||||
self.mox.StubOutWithMock(utils, 'temporary_chown')
|
||||
mock_tempchown = self.mox.CreateMockAnything()
|
||||
mock_tempchown = mock.MagicMock()
|
||||
utils.temporary_chown(self.TEST_VOLPATH).AndReturn(mock_tempchown)
|
||||
mock_tempchown.__enter__()
|
||||
mock_tempchown.__exit__(None, None, None)
|
||||
|
||||
self.mox.StubOutWithMock(fileutils, 'file_open')
|
||||
mock_fileopen = self.mox.CreateMockAnything()
|
||||
mock_fileopen = mock.MagicMock()
|
||||
fileutils.file_open(self.TEST_VOLPATH).AndReturn(mock_fileopen)
|
||||
mock_fileopen.__enter__()
|
||||
mock_fileopen.__exit__(None, None, None)
|
||||
|
||||
backup = {'volume_id': volume['id']}
|
||||
mock_servicebackup = self.mox.CreateMockAnything()
|
||||
mock_servicebackup.backup(backup, mox_lib.IgnoreArg())
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
self._driver.backup_volume(context, backup, mock_servicebackup)
|
||||
self.mox.VerifyAll()
|
||||
|
||||
def test_restore_backup(self):
|
||||
volume = {'id': '2', 'name': self.TEST_VOLNAME}
|
||||
|
||||
self.mox.StubOutWithMock(utils, 'temporary_chown')
|
||||
mock_tempchown = self.mox.CreateMockAnything()
|
||||
mock_tempchown = mock.MagicMock()
|
||||
utils.temporary_chown(self.TEST_VOLPATH).AndReturn(mock_tempchown)
|
||||
mock_tempchown.__enter__()
|
||||
mock_tempchown.__exit__(None, None, None)
|
||||
|
||||
self.mox.StubOutWithMock(fileutils, 'file_open')
|
||||
mock_fileopen = self.mox.CreateMockAnything()
|
||||
mock_fileopen = mock.MagicMock()
|
||||
fileutils.file_open(self.TEST_VOLPATH, 'wb').AndReturn(mock_fileopen)
|
||||
mock_fileopen.__enter__()
|
||||
mock_fileopen.__exit__(None, None, None)
|
||||
|
||||
backup = {'id': 123, 'volume_id': volume['id']}
|
||||
mock_servicebackup = self.mox.CreateMockAnything()
|
||||
mock_servicebackup.restore(backup, volume['id'], mox_lib.IgnoreArg())
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
self._driver.restore_backup(context, backup, volume,
|
||||
mock_servicebackup)
|
||||
self.mox.VerifyAll()
|
||||
|
@ -21,7 +21,7 @@ Unit Tests for remote procedure calls using queue
|
||||
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as db_exc
|
||||
|
@ -17,7 +17,7 @@
|
||||
import datetime
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import units
|
||||
@ -43,7 +43,6 @@ def create_configuration():
|
||||
class SolidFireVolumeTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
self.ctxt = context.get_admin_context()
|
||||
self._mox = mox.Mox()
|
||||
self.configuration = mox.MockObject(conf.Configuration)
|
||||
self.configuration.sf_allow_tenant_qos = True
|
||||
self.configuration.san_is_local = True
|
||||
|
@ -20,7 +20,7 @@ Test suite for VMware VMDK driver.
|
||||
from distutils import version as ver
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo_utils import units
|
||||
from oslo_vmware import api
|
||||
from oslo_vmware import exceptions
|
||||
|
@ -28,7 +28,7 @@ import time
|
||||
|
||||
import eventlet
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
@ -818,9 +818,6 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
self.assertEqual(volume_id, volume_ref.id)
|
||||
self.assertEqual("available", volume_ref.status)
|
||||
|
||||
self.mox.UnsetStubs()
|
||||
self.volume.delete_volume(self.context, volume_id)
|
||||
|
||||
def test_get_volume_different_tenant(self):
|
||||
"""Test can't get volume of another tenant when viewable_admin_meta."""
|
||||
volume = tests_utils.create_volume(self.context,
|
||||
@ -3102,10 +3099,6 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
self.assertEqual(snapshot_id, snapshot_ref.id)
|
||||
self.assertEqual("available", snapshot_ref.status)
|
||||
|
||||
self.mox.UnsetStubs()
|
||||
self.volume.delete_snapshot(self.context, snapshot_obj)
|
||||
self.volume.delete_volume(self.context, volume_id)
|
||||
|
||||
@test.testtools.skipIf(sys.platform == "darwin", "SKIP on OSX")
|
||||
def test_delete_no_dev_fails(self):
|
||||
"""Test delete snapshot with no dev file fails."""
|
||||
|
@ -22,7 +22,7 @@ import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo_config import cfg
|
||||
|
||||
from cinder.image import image_utils
|
||||
|
@ -9,7 +9,7 @@ coverage>=3.6
|
||||
discover
|
||||
fixtures>=0.3.14
|
||||
mock>=1.0
|
||||
mox>=0.5.3
|
||||
mox3>=0.7.0
|
||||
MySQL-python
|
||||
psycopg2
|
||||
oslotest>=1.5.1 # Apache-2.0
|
||||
|
Loading…
Reference in New Issue
Block a user