Stop using mox stubs in nova.tests.unit.console

remove stubs with newly introduced stub_out function
also use mock to replace old mox in console subfolder.

Part of blueprint remove-mox

Change-Id: Id4317ec0635f2acd85e839352b7c7ea7d9d35292
This commit is contained in:
jichenjc 2016-01-13 08:08:20 +08:00
parent 34cf19c8a4
commit 09b19d8e43
1 changed files with 5 additions and 10 deletions

View File

@ -22,7 +22,6 @@ from oslo_utils import importutils
from nova.compute import rpcapi as compute_rpcapi
from nova.console import api as console_api
from nova.console import rpcapi as console_rpcapi
from nova import context
from nova import db
from nova import exception
@ -148,12 +147,12 @@ class ConsoleAPITestCase(test.TestCase):
def _fake_db_console_get(_ctxt, _console_uuid, _instance_uuid):
return self.fake_console
self.stubs.Set(db, 'console_get', _fake_db_console_get)
self.stub_out('nova.db.console_get', _fake_db_console_get)
def _fake_db_console_get_all_by_instance(_ctxt, _instance_uuid,
columns_to_join):
return [self.fake_console]
self.stubs.Set(db, 'console_get_all_by_instance',
self.stub_out('nova.db.console_get_all_by_instance',
_fake_db_console_get_all_by_instance)
def test_get_consoles(self):
@ -165,15 +164,11 @@ class ConsoleAPITestCase(test.TestCase):
'fake_id')
self.assertEqual(console, self.fake_console)
def test_delete_console(self):
self.mox.StubOutWithMock(console_rpcapi.ConsoleAPI, 'remove_console')
console_rpcapi.ConsoleAPI.remove_console(self.context, 'fake_id')
self.mox.ReplayAll()
@mock.patch('nova.console.rpcapi.ConsoleAPI.remove_console')
def test_delete_console(self, mock_remove):
self.console_api.delete_console(self.context, self.fake_uuid,
'fake_id')
mock_remove.assert_called_once_with(self.context, 'fake_id')
@mock.patch.object(compute_rpcapi.ComputeAPI, 'get_console_topic',
return_value='compute.fake_host')