Fix some pylint errors in IPAM tests

W:121,15: Using type() instead of isinstance() for a typecheck.
E:123,20: Raising NoneType while only classes or instances are allowed
E:137,20: Raising NoneType while only classes or instances are allowed

There was also some incorrect indentation.

Trivialfix

Change-Id: I24aae1f41db80aa11405c024684773f73cd6dfbf
This commit is contained in:
Brian Haley
2017-01-26 10:52:52 -05:00
parent 4ae6790d82
commit 26128ac589
@@ -112,12 +112,10 @@ class TestDbBasePluginIpam(test_db_base.NeutronDbPluginV2TestCase):
def _get_allocate_mock(self, subnet_id, auto_ip='10.0.0.2',
fail_ip='127.0.0.1',
exception=None):
if exception is None:
exception = n_exc.InvalidInput(error_message='SomeError')
exception=n_exc.InvalidInput(
error_message='SomeError')):
def allocate_mock(request):
if type(request) == ipam_req.SpecificAddressRequest:
if isinstance(request, ipam_req.SpecificAddressRequest):
if request.address == netaddr.IPAddress(fail_ip):
raise exception
else:
@@ -127,15 +125,14 @@ class TestDbBasePluginIpam(test_db_base.NeutronDbPluginV2TestCase):
return allocate_mock
def _get_deallocate_mock(self, fail_ip='127.0.0.1', exception=None):
if exception is None:
exception = n_exc.InvalidInput(error_message='SomeError')
def _get_deallocate_mock(self, fail_ip='127.0.0.1',
exception=n_exc.InvalidInput(
error_message='SomeError')):
def deallocate_mock(ip):
if str(ip) == fail_ip:
raise exception
def deallocate_mock(ip):
if str(ip) == fail_ip:
raise exception
return deallocate_mock
return deallocate_mock
def _validate_allocate_calls(self, expected_calls, mocks):
self.assertTrue(mocks['subnets'].allocate.called)