Stop using mox in test_security_groups
This change replaces use of mox with mock in test_security_groups.py. Change-Id: Iebf98d401e3076f31d3169ae2ec4cb419f2bb60b Implements: blueprint remove-mox-newton
This commit is contained in:
parent
6b18b48269
commit
5867d406a4
|
@ -14,7 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from mox3 import mox
|
||||
from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import encodeutils
|
||||
|
@ -675,21 +674,21 @@ class TestSecurityGroupsV21(test.TestCase):
|
|||
self.manager._addSecurityGroup, self.req,
|
||||
UUID_SERVER, body)
|
||||
|
||||
def test_associate(self):
|
||||
@mock.patch.object(nova.db, 'instance_add_security_group')
|
||||
def test_associate(self, mock_add_security_group):
|
||||
self.stub_out('nova.db.instance_get', return_server)
|
||||
self.stub_out('nova.db.instance_get_by_uuid',
|
||||
return_server_by_uuid)
|
||||
self.mox.StubOutWithMock(nova.db, 'instance_add_security_group')
|
||||
nova.db.instance_add_security_group(mox.IgnoreArg(),
|
||||
mox.IgnoreArg(),
|
||||
mox.IgnoreArg())
|
||||
|
||||
self.stub_out('nova.db.security_group_get_by_name',
|
||||
return_security_group_without_instances)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
body = dict(addSecurityGroup=dict(name="test"))
|
||||
|
||||
self.manager._addSecurityGroup(self.req, UUID_SERVER, body)
|
||||
mock_add_security_group.assert_called_once_with(mock.ANY,
|
||||
mock.ANY,
|
||||
mock.ANY)
|
||||
|
||||
def test_disassociate_by_non_existing_security_group_name(self):
|
||||
self.stub_out('nova.db.instance_get', return_server)
|
||||
|
@ -766,21 +765,20 @@ class TestSecurityGroupsV21(test.TestCase):
|
|||
self.manager._removeSecurityGroup, self.req,
|
||||
UUID_SERVER, body)
|
||||
|
||||
def test_disassociate(self):
|
||||
@mock.patch.object(nova.db, 'instance_remove_security_group')
|
||||
def test_disassociate(self, mock_remove_sec_group):
|
||||
self.stub_out('nova.db.instance_get', return_server)
|
||||
self.stub_out('nova.db.instance_get_by_uuid',
|
||||
return_server_by_uuid)
|
||||
self.mox.StubOutWithMock(nova.db, 'instance_remove_security_group')
|
||||
nova.db.instance_remove_security_group(mox.IgnoreArg(),
|
||||
mox.IgnoreArg(),
|
||||
mox.IgnoreArg())
|
||||
self.stub_out('nova.db.security_group_get_by_name',
|
||||
return_security_group_by_name)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
body = dict(removeSecurityGroup=dict(name="test"))
|
||||
|
||||
self.manager._removeSecurityGroup(self.req, UUID_SERVER, body)
|
||||
mock_remove_sec_group.assert_called_once_with(mock.ANY,
|
||||
mock.ANY,
|
||||
mock.ANY)
|
||||
|
||||
|
||||
class TestSecurityGroupsV2(TestSecurityGroupsV21):
|
||||
|
|
Loading…
Reference in New Issue