Revision bdff03d5 kamaki/clients/network/test.py

b/kamaki/clients/network/test.py
399 399
    def test_update_subnet(self, subnets_put):
400 400
        for (
401 401
                name, allocation_pools, gateway_ip,
402
                subnet_id, ipv6, enable_dhcp) in product(
402
                ipv6, enable_dhcp) in product(
403 403
                    ('name', None), ('all pools', None), ('gip', None),
404
                    ('sid', None), (True, False, None), (True, False, None)):
404
                    (True, False, None), (True, False, None)):
405 405
            kwargs = dict(
406 406
                name=name, allocation_pools=allocation_pools,
407
                gateway_ip=gateway_ip, subnet_id=subnet_id,
408
                ipv6=ipv6, enable_dhcp=enable_dhcp)
409
            FakeObject.json, network_id, cidr = dict(subnet='rv'), 'name', 'cd'
407
                gateway_ip=gateway_ip, ipv6=ipv6, enable_dhcp=enable_dhcp)
408
            FakeObject.json, subnet_id = dict(subnet='rv'), 'sid'
410 409
            self.assertEqual(
411
                self.client.update_subnet(network_id, cidr, **kwargs), 'rv')
412
            req = dict(network_id=network_id, cidr=cidr)
413
            if kwargs.get('ipv6', None) not in (None, ):
414
                req['ip_version'] = 6 if kwargs.pop('ipv6') else 4
410
                self.client.update_subnet(subnet_id, **kwargs), 'rv')
411
            req = dict()
415 412
            for k, v in kwargs.items():
416 413
                if v not in (None, ):
417
                    req['id' if k == 'subnet_id' else k] = v
418
            expargs = dict(json_data=dict(subnet=req), success=201)
419
            self.assertEqual(subnets_put.mock_calls[-1], call(**expargs))
414
                    if k in ('ipv6', ):
415
                        req['ip_version'] = 6 if v else 4
416
                    else:
417
                        req[k] = v
418
            expargs = dict(json=dict(subnet=req), success=200)
419
            self.assertEqual(
420
                subnets_put.mock_calls[-1], call(subnet_id, **expargs))
420 421

  
421 422
    @patch(
422 423
        'kamaki.clients.network.NetworkClient.subnets_delete',

Also available in: Unified diff