Revision 77d1b504 kamaki/clients/compute/test.py

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

  

Also available in: Unified diff