summaryrefslogtreecommitdiff
path: root/novaclient/tests/unit/v2/test_floating_ips.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/tests/unit/v2/test_floating_ips.py')
-rw-r--r--novaclient/tests/unit/v2/test_floating_ips.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/novaclient/tests/unit/v2/test_floating_ips.py b/novaclient/tests/unit/v2/test_floating_ips.py
new file mode 100644
index 0000000..2b091a5
--- /dev/null
+++ b/novaclient/tests/unit/v2/test_floating_ips.py
@@ -0,0 +1,59 @@
1# Copyright (c) 2011 X.commerce, a business unit of eBay Inc.
2#
3# All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17from novaclient.tests.unit.fixture_data import client
18from novaclient.tests.unit.fixture_data import floatingips as data
19from novaclient.tests.unit import utils
20from novaclient.v2 import floating_ips
21
22
23class FloatingIPsTest(utils.FixturedTestCase):
24
25 client_fixture_class = client.V1
26 data_fixture_class = data.FloatingFixture
27
28 def test_list_floating_ips(self):
29 fips = self.cs.floating_ips.list()
30 self.assert_called('GET', '/os-floating-ips')
31 for fip in fips:
32 self.assertIsInstance(fip, floating_ips.FloatingIP)
33
34 def test_list_floating_ips_all_tenants(self):
35 fips = self.cs.floating_ips.list(all_tenants=True)
36 self.assert_called('GET', '/os-floating-ips?all_tenants=1')
37 for fip in fips:
38 self.assertIsInstance(fip, floating_ips.FloatingIP)
39
40 def test_delete_floating_ip(self):
41 fl = self.cs.floating_ips.list()[0]
42 fl.delete()
43 self.assert_called('DELETE', '/os-floating-ips/1')
44 self.cs.floating_ips.delete(1)
45 self.assert_called('DELETE', '/os-floating-ips/1')
46 self.cs.floating_ips.delete(fl)
47 self.assert_called('DELETE', '/os-floating-ips/1')
48
49 def test_create_floating_ip(self):
50 fl = self.cs.floating_ips.create()
51 self.assert_called('POST', '/os-floating-ips')
52 self.assertIsNone(fl.pool)
53 self.assertIsInstance(fl, floating_ips.FloatingIP)
54
55 def test_create_floating_ip_with_pool(self):
56 fl = self.cs.floating_ips.create('nova')
57 self.assert_called('POST', '/os-floating-ips')
58 self.assertEqual('nova', fl.pool)
59 self.assertIsInstance(fl, floating_ips.FloatingIP)