Switch to moxstubout and mockpatch from oslotest
The fixtures in nova/openstack/common will be removed as they have been removed from oslo-incubator. We should use the fixtures from oslotest. Note that oslotest uses mox3 instead of mox and some of the tests were failing as a result which have been fixed in this review. Only the failing tests have been fixed, so you will see some tests use a mix of mock and mox3 as a result. Based on feedback from Nova core, all existing references to 'import mox' have been switched over to mox3 as well. Change-Id: Ifa9dbb6f9bb1a358d815ae80cf928b65d5dcf5bd
This commit is contained in:
parent
72baac0852
commit
f9c96e1d35
|
@ -38,7 +38,9 @@ def update_instance_cache_with_nw_info(impl, context, instance,
|
|||
nw_info = None
|
||||
if nw_info is None:
|
||||
nw_info = impl._get_instance_nw_info(context, instance)
|
||||
|
||||
LOG.debug('Updating cache with info: %s', nw_info)
|
||||
|
||||
# NOTE(comstud): The save() method actually handles updating or
|
||||
# creating the instance. We don't need to retrieve the object
|
||||
# from the DB first.
|
||||
|
|
|
@ -39,6 +39,7 @@ from oslo.config import cfg
|
|||
from oslo.config import fixture as config_fixture
|
||||
from oslo.messaging import conffixture as messaging_conffixture
|
||||
from oslo.utils import timeutils
|
||||
from oslotest import moxstubout
|
||||
import testtools
|
||||
|
||||
from nova import context
|
||||
|
@ -49,7 +50,6 @@ from nova.network import manager as network_manager
|
|||
from nova import objects
|
||||
from nova.objects import base as objects_base
|
||||
from nova.openstack.common.fixture import logging as log_fixture
|
||||
from nova.openstack.common.fixture import moxstubout
|
||||
from nova.openstack.common import log as nova_logging
|
||||
from nova import paths
|
||||
from nova import rpc
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
import webob
|
||||
|
||||
from nova.api.ec2 import faults
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
from eventlet.green import httplib
|
||||
from lxml import etree
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import timeutils
|
||||
import webob
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils
|
||||
from webob import exc
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils
|
||||
from webob import exc
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
from lxml import etree
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack.compute.contrib import certificates as certificates_v2
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import datetime
|
||||
|
||||
from lxml import etree
|
||||
from oslotest import moxstubout
|
||||
|
||||
from nova.api.openstack.compute.contrib import migrations as migrations_v2
|
||||
from nova.api.openstack.compute.plugins.v3 import migrations as migrations_v21
|
||||
|
@ -22,7 +23,6 @@ from nova import context
|
|||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
from nova.openstack.common.fixture import moxstubout
|
||||
from nova import test
|
||||
|
||||
fake_migrations = [
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
from lxml import etree
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils
|
||||
import webob
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute.contrib import server_start_stop \
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
import uuid
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils
|
||||
import webob
|
||||
|
|
|
@ -22,7 +22,7 @@ import uuid
|
|||
|
||||
import iso8601
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
|
|
|
@ -17,7 +17,7 @@ import base64
|
|||
import uuid
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils
|
||||
import webob
|
||||
|
|
|
@ -20,7 +20,7 @@ Tests For Cells Messaging module
|
|||
import contextlib
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo import messaging as oslo_messaging
|
||||
from oslo.serialization import jsonutils
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
Tests For Cells RPC Communication Driver
|
||||
"""
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo import messaging as oslo_messaging
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import uuid
|
|||
|
||||
from eventlet import greenthread
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo import messaging
|
||||
from oslo.serialization import jsonutils
|
||||
|
@ -2767,7 +2767,8 @@ class ComputeTestCase(BaseTestCase):
|
|||
def test_reboot_hard_and_delete_and_rescued(self):
|
||||
self._test_reboot(False, True, True)
|
||||
|
||||
def test_reboot_fail(self):
|
||||
@mock.patch.object(jsonutils, 'to_primitive')
|
||||
def test_reboot_fail(self, mock_to_primitive):
|
||||
self._test_reboot(False, fail_reboot=True)
|
||||
|
||||
def test_reboot_fail_running(self):
|
||||
|
|
|
@ -19,7 +19,7 @@ import datetime
|
|||
|
||||
import iso8601
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.utils import timeutils
|
||||
|
||||
from nova.compute import api as compute_api
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
import iso8601
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import timeutils
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
|
||||
from nova.compute import manager as compute_manager
|
||||
from nova import context
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
|
||||
from nova.compute import power_state
|
||||
from nova.compute import utils as compute_utils
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
import contextlib
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo import messaging
|
||||
from oslo.serialization import jsonutils
|
||||
|
|
|
@ -18,7 +18,7 @@ Tests for Consoleauth Code.
|
|||
|
||||
"""
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.utils import timeutils
|
||||
|
||||
from nova.consoleauth import manager
|
||||
|
|
|
@ -19,7 +19,7 @@ import tempfile
|
|||
|
||||
import eventlet
|
||||
import fixtures
|
||||
import mox
|
||||
from mox3 import mox
|
||||
|
||||
from nova.api.ec2 import ec2utils
|
||||
from nova import context
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from neutronclient.common import exceptions as n_exc
|
||||
from neutronclient.v2_0 import client
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import itertools
|
|||
import uuid
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
|
||||
from nova.compute import flavors
|
||||
from nova import context
|
||||
|
|
|
@ -19,7 +19,7 @@ import datetime
|
|||
import os
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.concurrency import processutils
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils
|
||||
|
|
|
@ -19,7 +19,7 @@ import contextlib
|
|||
|
||||
import fixtures
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
import netaddr
|
||||
from oslo.concurrency import processutils
|
||||
from oslo.config import cfg
|
||||
|
|
|
@ -20,7 +20,7 @@ import copy
|
|||
import uuid
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from neutronclient.common import exceptions
|
||||
from neutronclient.v2_0 import client
|
||||
from oslo.config import cfg
|
||||
|
@ -2123,7 +2123,8 @@ class TestNeutronv2(TestNeutronv2Base):
|
|||
self.mox.StubOutWithMock(api, '_get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(api.db, 'instance_info_cache_update')
|
||||
for instance in instances:
|
||||
nw_info.json()
|
||||
nw_info.__str__().AndReturn('')
|
||||
nw_info.json().AndReturn({})
|
||||
api._get_instance_nw_info(mox.IgnoreArg(), instance).\
|
||||
AndReturn(nw_info)
|
||||
api.db.instance_info_cache_update(mox.IgnoreArg(),
|
||||
|
|
|
@ -18,7 +18,7 @@ Unit Tests for nova.network.rpcapi
|
|||
|
||||
import collections
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova import context
|
||||
|
|
|
@ -16,7 +16,7 @@ import datetime
|
|||
|
||||
import iso8601
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
import netaddr
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
Fakes For Scheduler tests.
|
||||
"""
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.serialization import jsonutils
|
||||
|
||||
from nova.compute import vm_states
|
||||
|
|
|
@ -18,7 +18,7 @@ Tests For Chance Scheduler.
|
|||
|
||||
import random
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
from nova.compute import utils as compute_utils
|
||||
|
|
|
@ -17,7 +17,7 @@ Tests For Filter Scheduler.
|
|||
"""
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
|
||||
from nova.compute import utils as compute_utils
|
||||
from nova.compute import vm_states
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
Unit Tests for nova.scheduler.rpcapi
|
||||
"""
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova import context
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
Tests For Scheduler
|
||||
"""
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova.compute import api as compute_api
|
||||
|
|
|
@ -19,7 +19,7 @@ import contextlib
|
|||
import uuid
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova.compute import flavors
|
||||
|
|
|
@ -17,10 +17,10 @@ Tests For Scheduler weights.
|
|||
"""
|
||||
|
||||
from oslo.serialization import jsonutils
|
||||
from oslotest import mockpatch
|
||||
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova.openstack.common.fixture import mockpatch
|
||||
from nova.scheduler import weights
|
||||
from nova import test
|
||||
from nova.tests.unit import matchers
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import os
|
||||
import tempfile
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova import context
|
||||
|
|
|
@ -19,7 +19,7 @@ Tests for Crypto module.
|
|||
import os
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.concurrency import processutils
|
||||
|
||||
from nova import crypto
|
||||
|
|
|
@ -21,7 +21,7 @@ Unit Tests for remote procedure calls using queue
|
|||
import sys
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.concurrency import processutils
|
||||
from oslo.config import cfg
|
||||
import testtools
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import __builtin__
|
||||
import datetime
|
||||
import functools
|
||||
import hashlib
|
||||
|
@ -22,7 +21,8 @@ import os.path
|
|||
import StringIO
|
||||
import tempfile
|
||||
|
||||
import mox
|
||||
import mock
|
||||
from mox3 import mox
|
||||
import netaddr
|
||||
from oslo.concurrency import processutils
|
||||
from oslo.config import cfg
|
||||
|
@ -181,32 +181,23 @@ class GenericUtilsTestCase(test.NoDBTestCase):
|
|||
|
||||
def test_read_modified_cached_file(self):
|
||||
self.mox.StubOutWithMock(os.path, "getmtime")
|
||||
self.mox.StubOutWithMock(__builtin__, 'open')
|
||||
os.path.getmtime(mox.IgnoreArg()).AndReturn(2)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
fake_contents = "lorem ipsum"
|
||||
fake_file = self.mox.CreateMockAnything()
|
||||
fake_file.read().AndReturn(fake_contents)
|
||||
fake_context_manager = self.mox.CreateMockAnything()
|
||||
fake_context_manager.__enter__().AndReturn(fake_file)
|
||||
fake_context_manager.__exit__(mox.IgnoreArg(),
|
||||
mox.IgnoreArg(),
|
||||
mox.IgnoreArg())
|
||||
m = mock.mock_open(read_data=fake_contents)
|
||||
with mock.patch("__builtin__.open", m, create=True):
|
||||
cache_data = {"data": 1123, "mtime": 1}
|
||||
self.reload_called = False
|
||||
|
||||
__builtin__.open(mox.IgnoreArg()).AndReturn(fake_context_manager)
|
||||
def test_reload(reloaded_data):
|
||||
self.assertEqual(reloaded_data, fake_contents)
|
||||
self.reload_called = True
|
||||
|
||||
self.mox.ReplayAll()
|
||||
cache_data = {"data": 1123, "mtime": 1}
|
||||
self.reload_called = False
|
||||
|
||||
def test_reload(reloaded_data):
|
||||
self.assertEqual(reloaded_data, fake_contents)
|
||||
self.reload_called = True
|
||||
|
||||
data = utils.read_cached_file("/this/is/a/fake", cache_data,
|
||||
reload_func=test_reload)
|
||||
self.assertEqual(data, fake_contents)
|
||||
self.assertTrue(self.reload_called)
|
||||
data = utils.read_cached_file("/this/is/a/fake", cache_data,
|
||||
reload_func=test_reload)
|
||||
self.assertEqual(data, fake_contents)
|
||||
self.assertTrue(self.reload_called)
|
||||
|
||||
def test_generate_password(self):
|
||||
password = utils.generate_password()
|
||||
|
|
|
@ -120,7 +120,8 @@ class APITestCase(test.NoDBTestCase):
|
|||
self.mox.StubOutWithMock(mounter, 'get_dev')
|
||||
self.mox.StubOutWithMock(mounter, 'unget_dev')
|
||||
self.mox.StubOutWithMock(api, 'resize2fs')
|
||||
self.mox.StubOutWithMock(mount.Mount, 'instance_for_format')
|
||||
self.mox.StubOutWithMock(mount.Mount, 'instance_for_format',
|
||||
use_mock_anything=True)
|
||||
|
||||
api.can_resize_image(imgfile, imgsize).AndReturn(True)
|
||||
utils.execute('qemu-img', 'resize', imgfile, imgsize)
|
||||
|
|
|
@ -31,7 +31,7 @@ from eventlet import greenthread
|
|||
import fixtures
|
||||
from lxml import etree
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.concurrency import lockutils
|
||||
from oslo.concurrency import processutils
|
||||
from oslo.config import cfg
|
||||
|
@ -11396,7 +11396,10 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
network_info, image_meta, rescue_password)
|
||||
self.mox.VerifyAll()
|
||||
|
||||
def test_rescue_config_drive(self):
|
||||
@mock.patch(
|
||||
'nova.virt.configdrive.ConfigDriveBuilder.add_instance_metadata')
|
||||
@mock.patch('nova.virt.configdrive.ConfigDriveBuilder.make_drive')
|
||||
def test_rescue_config_drive(self, mock_make, mock_add):
|
||||
instance = self._create_instance()
|
||||
uuid = instance.uuid
|
||||
configdrive_path = uuid + '/disk.config.rescue'
|
||||
|
@ -11418,8 +11421,6 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
self.mox.StubOutWithMock(imagebackend.Image, 'cache')
|
||||
self.mox.StubOutWithMock(instance_metadata.InstanceMetadata,
|
||||
'__init__')
|
||||
self.mox.StubOutWithMock(configdrive, 'ConfigDriveBuilder')
|
||||
self.mox.StubOutWithMock(configdrive.ConfigDriveBuilder, 'make_drive')
|
||||
self.mox.StubOutWithMock(self.libvirtconnection, '_get_guest_xml')
|
||||
self.mox.StubOutWithMock(self.libvirtconnection, '_destroy')
|
||||
self.mox.StubOutWithMock(self.libvirtconnection, '_create_domain')
|
||||
|
@ -11455,14 +11456,6 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
content=mox.IgnoreArg(),
|
||||
extra_md=mox.IgnoreArg(),
|
||||
network_info=mox.IgnoreArg())
|
||||
cdb = self.mox.CreateMockAnything()
|
||||
m = configdrive.ConfigDriveBuilder(instance_md=mox.IgnoreArg())
|
||||
m.AndReturn(cdb)
|
||||
# __enter__ and __exit__ are required by "with"
|
||||
cdb.__enter__().AndReturn(cdb)
|
||||
cdb.make_drive(mox.Regex(configdrive_path))
|
||||
cdb.__exit__(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()
|
||||
).AndReturn(None)
|
||||
image_meta = {'id': 'fake', 'name': 'fake'}
|
||||
self.libvirtconnection._get_guest_xml(mox.IgnoreArg(), instance,
|
||||
network_info, mox.IgnoreArg(),
|
||||
|
@ -11480,6 +11473,11 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
image_meta, rescue_password)
|
||||
self.mox.VerifyAll()
|
||||
|
||||
mock_add.assert_any_call(mock.ANY)
|
||||
expected_call = [mock.call(os.path.join(CONF.instances_path,
|
||||
configdrive_path))]
|
||||
mock_make.assert_has_calls(expected_call)
|
||||
|
||||
@mock.patch('shutil.rmtree')
|
||||
@mock.patch('nova.utils.execute')
|
||||
@mock.patch('os.path.exists')
|
||||
|
|
|
@ -20,7 +20,7 @@ from xml.dom import minidom
|
|||
|
||||
from lxml import etree
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.concurrency import lockutils
|
||||
|
||||
from nova.compute import utils as compute_utils
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
import fixtures
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
|
||||
from nova import context
|
||||
from nova.image import glance
|
||||
|
|
|
@ -26,7 +26,7 @@ import datetime
|
|||
|
||||
from eventlet import greenthread
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import mox
|
||||
from mox3 import mox
|
||||
import pkg_resources
|
||||
import six
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import uuid
|
|||
from eventlet import greenthread
|
||||
import fixtures
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.concurrency import lockutils
|
||||
from oslo.concurrency import processutils
|
||||
from oslo.config import cfg
|
||||
|
|
|
@ -23,7 +23,7 @@ import os
|
|||
import re
|
||||
|
||||
import mock
|
||||
import mox
|
||||
from mox3 import mox
|
||||
from oslo.concurrency import lockutils
|
||||
from oslo.config import cfg
|
||||
from oslo.config import fixture as config_fixture
|
||||
|
|
|
@ -195,7 +195,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
|||
def test_reserve_volume(self):
|
||||
cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
|
||||
self.mox.StubOutWithMock(self.cinderclient.volumes,
|
||||
'reserve')
|
||||
'reserve',
|
||||
use_mock_anything=True)
|
||||
self.cinderclient.volumes.reserve('id1')
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -204,7 +205,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
|||
def test_unreserve_volume(self):
|
||||
cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
|
||||
self.mox.StubOutWithMock(self.cinderclient.volumes,
|
||||
'unreserve')
|
||||
'unreserve',
|
||||
use_mock_anything=True)
|
||||
self.cinderclient.volumes.unreserve('id1')
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -213,7 +215,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
|||
def test_begin_detaching(self):
|
||||
cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
|
||||
self.mox.StubOutWithMock(self.cinderclient.volumes,
|
||||
'begin_detaching')
|
||||
'begin_detaching',
|
||||
use_mock_anything=True)
|
||||
self.cinderclient.volumes.begin_detaching('id1')
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -222,7 +225,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
|||
def test_roll_detaching(self):
|
||||
cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
|
||||
self.mox.StubOutWithMock(self.cinderclient.volumes,
|
||||
'roll_detaching')
|
||||
'roll_detaching',
|
||||
use_mock_anything=True)
|
||||
self.cinderclient.volumes.roll_detaching('id1')
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -253,7 +257,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
|||
def test_detach(self):
|
||||
cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
|
||||
self.mox.StubOutWithMock(self.cinderclient.volumes,
|
||||
'detach')
|
||||
'detach',
|
||||
use_mock_anything=True)
|
||||
self.cinderclient.volumes.detach('id1')
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -262,7 +267,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
|||
def test_initialize_connection(self):
|
||||
cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
|
||||
self.mox.StubOutWithMock(self.cinderclient.volumes,
|
||||
'initialize_connection')
|
||||
'initialize_connection',
|
||||
use_mock_anything=True)
|
||||
self.cinderclient.volumes.initialize_connection('id1', 'connector')
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -271,7 +277,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
|||
def test_terminate_connection(self):
|
||||
cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
|
||||
self.mox.StubOutWithMock(self.cinderclient.volumes,
|
||||
'terminate_connection')
|
||||
'terminate_connection',
|
||||
use_mock_anything=True)
|
||||
self.cinderclient.volumes.terminate_connection('id1', 'connector')
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -280,7 +287,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
|||
def test_delete(self):
|
||||
cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
|
||||
self.mox.StubOutWithMock(self.cinderclient.volumes,
|
||||
'delete')
|
||||
'delete',
|
||||
use_mock_anything=True)
|
||||
self.cinderclient.volumes.delete('id1')
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -340,7 +348,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
|||
def test_delete_snapshot(self):
|
||||
cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
|
||||
self.mox.StubOutWithMock(self.cinderclient.volume_snapshots,
|
||||
'delete')
|
||||
'delete',
|
||||
use_mock_anything=True)
|
||||
self.cinderclient.volume_snapshots.delete('id1')
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -429,7 +438,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
|||
def test_update_snapshot_status(self):
|
||||
cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
|
||||
self.mox.StubOutWithMock(self.cinderclient.volume_snapshots,
|
||||
'update_snapshot_status')
|
||||
'update_snapshot_status',
|
||||
use_mock_anything=True)
|
||||
self.cinderclient.volume_snapshots.update_snapshot_status(
|
||||
'id1', {'status': 'error', 'progress': '90%'})
|
||||
self.mox.ReplayAll()
|
||||
|
@ -438,7 +448,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
|||
def test_get_volume_encryption_metadata(self):
|
||||
cinder.cinderclient(self.ctx).AndReturn(self.cinderclient)
|
||||
self.mox.StubOutWithMock(self.cinderclient.volumes,
|
||||
'get_encryption_metadata')
|
||||
'get_encryption_metadata',
|
||||
use_mock_anything=True)
|
||||
self.cinderclient.volumes.\
|
||||
get_encryption_metadata({'encryption_key_id': 'fake_key'})
|
||||
self.mox.ReplayAll()
|
||||
|
|
|
@ -10,6 +10,7 @@ fixtures>=0.3.14
|
|||
libvirt-python>=1.2.5 # LGPLv2+
|
||||
mock>=1.0
|
||||
mox>=0.5.3
|
||||
mox3>=0.7.0
|
||||
MySQL-python
|
||||
psycopg2
|
||||
pylint>=1.3.0 # GNU GPL v2
|
||||
|
|
Loading…
Reference in New Issue