fix pep8 and UT issue

fix latest pep8 and UT issues

Change-Id: I9a3b7f55ec68a9944eb7513fca4c7f521642e49e
This commit is contained in:
terryyao 2014-12-08 10:52:56 +08:00
parent e506e9a9b4
commit 3699879307
3 changed files with 19 additions and 32 deletions

View File

@ -1,5 +1,5 @@
import unittest
import mox
import mock
import neutron.db.api as db_api
from powervc.neutron.api.powervc_rpc import PVCRpcCallbacks
@ -30,17 +30,9 @@ def dummy():
class TestSyncInstance(unittest.TestCase):
def setUp(self):
# Disable DB init.
db_api.get_session = dummy
db_api.configure_db = dummy
self._db = powervc_db_v2.PowerVCAgentDB()
powervc_db_v2.PowerVCAgentDB = mock.MagicMock()
self._callback = PVCRpcCallbacks(self)
# Replace with the dummy DB.
self._callback.db = self._db
self.moxer = mox.Mox()
def get_db_api(self):
return self._db
self._callback.db = mock.MagicMock()
def tearDown(self):
pass
@ -59,15 +51,8 @@ class TestSyncInstance(unittest.TestCase):
context = FakeCTX()
self.moxer.StubOutWithMock(self._db, "get_network")
self._db.get_network(local_id=id_in).AndReturn(id_out)
self.moxer.ReplayAll()
self._callback.db.get_network = mock.MagicMock(return_value=id_out)
rtn = self._callback.get_pvc_network_uuid(context, id_in)
self.moxer.VerifyAll()
self.moxer.UnsetStubs()
print str(rtn)
return rtn

View File

@ -2,8 +2,9 @@
from novaclient import base
from novaclient import exceptions
from powervc.common.gettextutils import _
from novaclient import utils
from novaclient.openstack.common import cliutils
from powervc.common.gettextutils import _
class HostMaintenanceResource(base.Resource):
@ -41,16 +42,16 @@ class HostMaintenanceManager(base.Manager):
return obj
@utils.arg('host',
@cliutils.arg('host',
metavar='<host>',
help='Name of a host.')
@utils.arg('--set-status', choices=["enable", "disable"],
@cliutils.arg('--set-status', choices=["enable", "disable"],
metavar="<enable|disable>",
help='To enable or disable the host maintenance mode.')
@utils.arg('--migrate', choices=["active-only", "all", "none"],
@cliutils.arg('--migrate', choices=["active-only", "all", "none"],
metavar="<all|active-only|none>",
help='Which kinds of instances to migrate.')
@utils.arg('--target-host',
@cliutils.arg('--target-host',
metavar='<target host>',
help='Which service host instances would be migrated to.')
def do_host_maintenance(cs, args):

View File

@ -498,6 +498,7 @@ class PowerVCDriverTestCase(test.NoDBTestCase):
def test_detach_interface_with_no_local_id_match(self):
instance = MagicMock()
detach_instance = pvcIns
def detach_response(pvc_id):
if pvc_id == 'powervc-port-id-77774'\
or pvc_id == 'powervc-port-id-77775':