Revision 77d1b504

b/Changelog
1 1
CHANGELOG for version 0.10
2 2

  
3
Bug Fixes:
4

  
5
Changes:
6

  
7
Features:
8

  
3 9

  
b/kamaki/clients/compute/rest_api.py
241 241
    def floating_ip_pools_get(self, tenant_id, success=200, **kwargs):
242 242
        path = path4url(tenant_id, 'os-floating-ip-pools')
243 243
        return self.get(path, success=success, **kwargs)
244

  
245
    def floating_ips_get(self, tenant_id, success=200, **kwargs):
246
        path = path4url(tenant_id, 'os-floating-ips')
247
        return self.get(path, success=success, **kwargs)
248

  
249
    def floating_ips_post(self, tenant_id, json_data, success=201, **kwargs):
250
        path = path4url(tenant_id, 'os-floating-ips')
251
        if json_data is not None:
252
            json_data = json.dumps(json_data)
253
            self.set_header('Content-Type', 'application/json')
254
            self.set_header('Content-Length', len(json_data))
255
        return self.post(path, data=json_data, success=success, **kwargs)
256

  
257
    def floating_ip_get(self, tenant_id, success=200, **kwargs):
258
        path = path4url(tenant_id, 'os-floating-ip')
259
        return self.get(path, success=success, **kwargs)
260

  
261
    def floating_ip_delete(self, tenant_id, success=204, **kwargs):
262
        path = path4url(tenant_id, 'os-floating-ip')
263
        return self.delete(path, success=success, **kwargs)
b/kamaki/clients/compute/test.py
240 240
                '/%s/os-floating-ip-pools' % tenant_id,
241 241
                success=success, **kwargs))
242 242

  
243
    @patch('%s.get' % rest_pkg, return_value=FR())
244
    def test_floating_ips_get(self, get):
245
        for args in product(
246
                ('tenant1', 'tenant2'),
247
                (200, 204),
248
                ({}, {'k': 'v'})):
249
            tenant_id, success, kwargs = args
250
            r = self.client.floating_ips_get(tenant_id, success, **kwargs)
251
            self.assertTrue(isinstance(r, FR))
252
            self.assertEqual(get.mock_calls[-1], call(
253
                '/%s/os-floating-ips' % tenant_id,
254
                success=success, **kwargs))
255

  
256
    @patch('%s.set_header' % rest_pkg)
257
    @patch('%s.post' % rest_pkg, return_value=FR())
258
    def test_floating_ips_post(self, post, SH):
259
        for args in product(
260
                ('tenant1', 'tenant2'),
261
                (None, [dict(json="data"), dict(data="json")]),
262
                (202, 204),
263
                ({}, {'k': 'v'})):
264
            (tenant_id, json_data, success, kwargs) = args
265
            self.client.floating_ips_post(*args[:3], **kwargs)
266
            if json_data:
267
                json_data = dumps(json_data)
268
                self.assertEqual(SH.mock_calls[-2:], [
269
                    call('Content-Type', 'application/json'),
270
                    call('Content-Length', len(json_data))])
271
            self.assertEqual(post.mock_calls[-1], call(
272
                '/%s/os-floating-ips' % tenant_id,
273
                data=json_data, success=success,
274
                **kwargs))
275

  
276
    @patch('%s.get' % rest_pkg, return_value=FR())
277
    def test_floating_ip_get(self, get):
278
        for args in product(
279
                ('tenant1', 'tenant2'),
280
                (200, 204),
281
                ({}, {'k': 'v'})):
282
            tenant_id, success, kwargs = args
283
            r = self.client.floating_ip_get(tenant_id, success, **kwargs)
284
            self.assertTrue(isinstance(r, FR))
285
            self.assertEqual(get.mock_calls[-1], call(
286
                '/%s/os-floating-ip' % tenant_id,
287
                success=success, **kwargs))
288

  
289
    @patch('%s.delete' % rest_pkg, return_value=FR())
290
    def test_floating_ip_delete(self, delete):
291
        for args in product(
292
                ('tenant1', 'tenant2'),
293
                (204,),
294
                ({}, {'k': 'v'})):
295
            tenant_id, success, kwargs = args
296
            r = self.client.floating_ip_delete(tenant_id, success, **kwargs)
297
            self.assertTrue(isinstance(r, FR))
298
            self.assertEqual(delete.mock_calls[-1], call(
299
                '/%s/os-floating-ip' % tenant_id,
300
                success=success, **kwargs))
301

  
243 302

  
244 303
class ComputeClient(TestCase):
245 304

  
b/kamaki/clients/cyclades/rest_api.py
169 169
    def floating_ip_pools_get(self, success=200, **kwargs):
170 170
        path = path4url('os-floating-ip-pools')
171 171
        return self.get(path, success=success, **kwargs)
172

  
173
    def floating_ips_get(self, success=200, **kwargs):
174
        path = path4url('os-floating-ips')
175
        return self.get(path, success=success, **kwargs)
176

  
177
    def floating_ips_post(self, json_data, success=201, **kwargs):
178
        path = path4url('os-floating-ips')
179
        if json_data is not None:
180
            json_data = json.dumps(json_data)
181
            self.set_header('Content-Type', 'application/json')
182
            self.set_header('Content-Length', len(json_data))
183
        return self.post(path, data=json_data, success=success, **kwargs)
184

  
185
    def floating_ip_get(self, floating_ip_id, success=200, **kwargs):
186
        path = path4url('os-floating-ip', floating_ip_id)
187
        return self.get(path, success=success, **kwargs)
188

  
189
    def floating_ip_delete(self, floating_ip_id, success=200, **kwargs):
190
        path = path4url('os-floating-ip', floating_ip_id)
191
        return self.delete(path, success=success, **kwargs)
b/kamaki/clients/cyclades/test.py
34 34
from mock import patch, call
35 35
from unittest import TestCase
36 36
from itertools import product
37
from json import dumps
37 38

  
38 39
from kamaki.clients import ClientError, cyclades
39 40

  
......
215 216
            self.assertEqual(get.mock_calls[-1], call(
216 217
                '/os-floating-ip-pools', success=success, **kwargs))
217 218

  
219
    @patch('%s.get' % rest_pkg, return_value=FR())
220
    def test_floating_ips_get(self, get):
221
        for args in product(
222
                (200, 204),
223
                ({}, {'k': 'v'})):
224
            success, kwargs = args
225
            r = self.client.floating_ips_get(success, **kwargs)
226
            self.assertTrue(isinstance(r, FR))
227
            self.assertEqual(get.mock_calls[-1], call(
228
                '/os-floating-ips', success=success, **kwargs))
229

  
230
    @patch('%s.set_header' % rest_pkg)
231
    @patch('%s.post' % rest_pkg, return_value=FR())
232
    def test_floating_ips_post(self, post, SH):
233
        for args in product(
234
                (None, [dict(json="data"), dict(data="json")]),
235
                (202, 204),
236
                ({}, {'k': 'v'})):
237
            (json_data, success, kwargs) = args
238
            self.client.floating_ips_post(*args[:2], **kwargs)
239
            if json_data:
240
                json_data = dumps(json_data)
241
                self.assertEqual(SH.mock_calls[-2:], [
242
                    call('Content-Type', 'application/json'),
243
                    call('Content-Length', len(json_data))])
244
            self.assertEqual(post.mock_calls[-1], call(
245
                '/os-floating-ips',
246
                data=json_data, success=success,
247
                **kwargs))
248

  
249
    @patch('%s.get' % rest_pkg, return_value=FR())
250
    def test_floating_ip_get(self, get):
251
        for args in product(
252
                ('fip1', 'fip2'),
253
                (200, 204),
254
                ({}, {'k': 'v'})):
255
            fip, success, kwargs = args
256
            r = self.client.floating_ip_get(fip, success, **kwargs)
257
            self.assertTrue(isinstance(r, FR))
258
            self.assertEqual(get.mock_calls[-1], call(
259
                '/os-floating-ip/%s' % fip, success=success, **kwargs))
260

  
261
    @patch('%s.delete' % rest_pkg, return_value=FR())
262
    def test_floating_ip_delete(self, delete):
263
        for args in product(
264
                ('fip1', 'fip2'),
265
                (200, 204),
266
                ({}, {'k': 'v'})):
267
            fip, success, kwargs = args
268
            r = self.client.floating_ip_delete(fip, success, **kwargs)
269
            self.assertTrue(isinstance(r, FR))
270
            self.assertEqual(delete.mock_calls[-1], call(
271
                '/os-floating-ip/%s' % fip, success=success, **kwargs))
272

  
218 273

  
219 274
class CycladesClient(TestCase):
220 275

  

Also available in: Unified diff