fix pep8 and UT issue
fix latest pep8 and UT issues Change-Id: I9a3b7f55ec68a9944eb7513fca4c7f521642e49e
This commit is contained in:
parent
e506e9a9b4
commit
3699879307
@ -1,5 +1,5 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import mox
|
import mock
|
||||||
|
|
||||||
import neutron.db.api as db_api
|
import neutron.db.api as db_api
|
||||||
from powervc.neutron.api.powervc_rpc import PVCRpcCallbacks
|
from powervc.neutron.api.powervc_rpc import PVCRpcCallbacks
|
||||||
@ -30,17 +30,9 @@ def dummy():
|
|||||||
class TestSyncInstance(unittest.TestCase):
|
class TestSyncInstance(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# Disable DB init.
|
powervc_db_v2.PowerVCAgentDB = mock.MagicMock()
|
||||||
db_api.get_session = dummy
|
|
||||||
db_api.configure_db = dummy
|
|
||||||
self._db = powervc_db_v2.PowerVCAgentDB()
|
|
||||||
self._callback = PVCRpcCallbacks(self)
|
self._callback = PVCRpcCallbacks(self)
|
||||||
# Replace with the dummy DB.
|
self._callback.db = mock.MagicMock()
|
||||||
self._callback.db = self._db
|
|
||||||
self.moxer = mox.Mox()
|
|
||||||
|
|
||||||
def get_db_api(self):
|
|
||||||
return self._db
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
pass
|
||||||
@ -59,15 +51,8 @@ class TestSyncInstance(unittest.TestCase):
|
|||||||
|
|
||||||
context = FakeCTX()
|
context = FakeCTX()
|
||||||
|
|
||||||
self.moxer.StubOutWithMock(self._db, "get_network")
|
self._callback.db.get_network = mock.MagicMock(return_value=id_out)
|
||||||
self._db.get_network(local_id=id_in).AndReturn(id_out)
|
|
||||||
|
|
||||||
self.moxer.ReplayAll()
|
|
||||||
|
|
||||||
rtn = self._callback.get_pvc_network_uuid(context, id_in)
|
rtn = self._callback.get_pvc_network_uuid(context, id_in)
|
||||||
|
|
||||||
self.moxer.VerifyAll()
|
|
||||||
self.moxer.UnsetStubs()
|
|
||||||
|
|
||||||
print str(rtn)
|
print str(rtn)
|
||||||
return rtn
|
return rtn
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
from novaclient import base
|
from novaclient import base
|
||||||
from novaclient import exceptions
|
from novaclient import exceptions
|
||||||
from powervc.common.gettextutils import _
|
|
||||||
from novaclient import utils
|
from novaclient import utils
|
||||||
|
from novaclient.openstack.common import cliutils
|
||||||
|
from powervc.common.gettextutils import _
|
||||||
|
|
||||||
|
|
||||||
class HostMaintenanceResource(base.Resource):
|
class HostMaintenanceResource(base.Resource):
|
||||||
@ -41,18 +42,18 @@ class HostMaintenanceManager(base.Manager):
|
|||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('host',
|
@cliutils.arg('host',
|
||||||
metavar='<host>',
|
metavar='<host>',
|
||||||
help='Name of a host.')
|
help='Name of a host.')
|
||||||
@utils.arg('--set-status', choices=["enable", "disable"],
|
@cliutils.arg('--set-status', choices=["enable", "disable"],
|
||||||
metavar="<enable|disable>",
|
metavar="<enable|disable>",
|
||||||
help='To enable or disable the host maintenance mode.')
|
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>",
|
metavar="<all|active-only|none>",
|
||||||
help='Which kinds of instances to migrate.')
|
help='Which kinds of instances to migrate.')
|
||||||
@utils.arg('--target-host',
|
@cliutils.arg('--target-host',
|
||||||
metavar='<target host>',
|
metavar='<target host>',
|
||||||
help='Which service host instances would be migrated to.')
|
help='Which service host instances would be migrated to.')
|
||||||
def do_host_maintenance(cs, args):
|
def do_host_maintenance(cs, args):
|
||||||
"""Enable maintenance mode for a hypervisor."""
|
"""Enable maintenance mode for a hypervisor."""
|
||||||
if not args.set_status:
|
if not args.set_status:
|
||||||
|
@ -498,6 +498,7 @@ class PowerVCDriverTestCase(test.NoDBTestCase):
|
|||||||
def test_detach_interface_with_no_local_id_match(self):
|
def test_detach_interface_with_no_local_id_match(self):
|
||||||
instance = MagicMock()
|
instance = MagicMock()
|
||||||
detach_instance = pvcIns
|
detach_instance = pvcIns
|
||||||
|
|
||||||
def detach_response(pvc_id):
|
def detach_response(pvc_id):
|
||||||
if pvc_id == 'powervc-port-id-77774'\
|
if pvc_id == 'powervc-port-id-77774'\
|
||||||
or pvc_id == 'powervc-port-id-77775':
|
or pvc_id == 'powervc-port-id-77775':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user