Merge "Fix some pylint errors in IPAM tests"

This commit is contained in:
Jenkins 2017-02-03 09:58:50 +00:00 committed by Gerrit Code Review
commit cc4c7bd4ab
1 changed files with 10 additions and 13 deletions

View File

@ -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)