From 052b7fe901d2ab5ce4f493e3f67aa5941efc4777 Mon Sep 17 00:00:00 2001 From: Matt Dietz Date: Fri, 9 Mar 2012 17:11:16 -0600 Subject: [PATCH] Fixes lp915212 Adds gateway as an optional paramter to the ip block creation Change-Id: Ie6c80a0712b8dd6f48840efab7af2e18b6cedbf9 --- melange/client/ipam_client.py | 6 ++++-- melange/client/tests/unit/test_ipam_client.py | 18 ++++++++++++++++++ tools/test-requires | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/melange/client/ipam_client.py b/melange/client/ipam_client.py index 921f299..f2a6554 100644 --- a/melange/client/ipam_client.py +++ b/melange/client/ipam_client.py @@ -122,11 +122,13 @@ class IpBlockClient(BaseClient): auth_client, tenant_id) - def create(self, type, cidr, network_id=None, policy_id=None): + def create(self, type, cidr, network_id=None, policy_id=None, + gateway=None): return self.resource.create(type=type, cidr=cidr, network_id=network_id, - policy_id=policy_id) + policy_id=policy_id, + gateway=gateway) def list(self): return self.resource.all() diff --git a/melange/client/tests/unit/test_ipam_client.py b/melange/client/tests/unit/test_ipam_client.py index 3e1f1e0..86561ab 100644 --- a/melange/client/tests/unit/test_ipam_client.py +++ b/melange/client/tests/unit/test_ipam_client.py @@ -16,6 +16,8 @@ # License for the specific language governing permissions and limitations # under the License. +import mock + from melange.client import ipam_client from melange.client import tests @@ -34,3 +36,19 @@ class TestFactory(tests.BaseTest): "Factory has no attribute " "non_existent_client", lambda: factory.non_existent_client) + + +class TestIpBlockCreate(tests.BaseTest): + + def test_create_ip_block_with_gateway(self): + factory = ipam_client.Factory("host", "8080") + client = ipam_client.IpBlockClient(factory._client, + factory._auth_client, 'fake') + with mock.patch('melange.client.ipam_client.Resource.create') as patch: + client.create(type='public', cidr='10.0.0.0/24', + gateway='10.0.0.1') + patch.assert_called_with(type='public', + cidr='10.0.0.0/24', + network_id=None, + policy_id=None, + gateway='10.0.0.1') diff --git a/tools/test-requires b/tools/test-requires index 4de4b4a..bd547f8 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -2,6 +2,7 @@ distribute>=0.6.24 coverage +mock mox nose nosexcover