summaryrefslogtreecommitdiff
path: root/novaclient/tests/unit/v2/test_floating_ips_bulk.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/tests/unit/v2/test_floating_ips_bulk.py')
-rw-r--r--novaclient/tests/unit/v2/test_floating_ips_bulk.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/novaclient/tests/unit/v2/test_floating_ips_bulk.py b/novaclient/tests/unit/v2/test_floating_ips_bulk.py
new file mode 100644
index 0000000..69b553f
--- /dev/null
+++ b/novaclient/tests/unit/v2/test_floating_ips_bulk.py
@@ -0,0 +1,64 @@
1# Copyright 2012 IBM Corp.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from novaclient.tests.unit.fixture_data import client
17from novaclient.tests.unit.fixture_data import floatingips as data
18from novaclient.tests.unit import utils
19from novaclient.v2 import floating_ips_bulk
20
21
22class FloatingIPsBulkTest(utils.FixturedTestCase):
23
24 client_fixture_class = client.V1
25 data_fixture_class = data.BulkFixture
26
27 def test_list_floating_ips_bulk(self):
28 fl = self.cs.floating_ips_bulk.list()
29 self.assert_called('GET', '/os-floating-ips-bulk')
30 [self.assertIsInstance(f, floating_ips_bulk.FloatingIP)
31 for f in fl]
32
33 def test_list_floating_ips_bulk_host_filter(self):
34 fl = self.cs.floating_ips_bulk.list('testHost')
35 self.assert_called('GET', '/os-floating-ips-bulk/testHost')
36 [self.assertIsInstance(f, floating_ips_bulk.FloatingIP)
37 for f in fl]
38
39 def test_create_floating_ips_bulk(self):
40 fl = self.cs.floating_ips_bulk.create('192.168.1.0/30')
41 body = {'floating_ips_bulk_create': {'ip_range': '192.168.1.0/30'}}
42 self.assert_called('POST', '/os-floating-ips-bulk', body)
43 self.assertEqual(fl.ip_range,
44 body['floating_ips_bulk_create']['ip_range'])
45
46 def test_create_floating_ips_bulk_with_pool_and_host(self):
47 fl = self.cs.floating_ips_bulk.create('192.168.1.0/30', 'poolTest',
48 'interfaceTest')
49 body = {'floating_ips_bulk_create': {
50 'ip_range': '192.168.1.0/30', 'pool': 'poolTest',
51 'interface': 'interfaceTest'}}
52 self.assert_called('POST', '/os-floating-ips-bulk', body)
53 self.assertEqual(fl.ip_range,
54 body['floating_ips_bulk_create']['ip_range'])
55 self.assertEqual(fl.pool,
56 body['floating_ips_bulk_create']['pool'])
57 self.assertEqual(fl.interface,
58 body['floating_ips_bulk_create']['interface'])
59
60 def test_delete_floating_ips_bulk(self):
61 fl = self.cs.floating_ips_bulk.delete('192.168.1.0/30')
62 body = {'ip_range': '192.168.1.0/30'}
63 self.assert_called('PUT', '/os-floating-ips-bulk/delete', body)
64 self.assertEqual(fl.floating_ips_bulk_delete, body['ip_range'])