summaryrefslogtreecommitdiff
path: root/novaclient/tests/unit/v2/test_networks.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/tests/unit/v2/test_networks.py')
-rw-r--r--novaclient/tests/unit/v2/test_networks.py106
1 files changed, 106 insertions, 0 deletions
diff --git a/novaclient/tests/unit/v2/test_networks.py b/novaclient/tests/unit/v2/test_networks.py
new file mode 100644
index 0000000..a45ba80
--- /dev/null
+++ b/novaclient/tests/unit/v2/test_networks.py
@@ -0,0 +1,106 @@
1#
2# Licensed under the Apache License, Version 2.0 (the "License"); you may
3# not use this file except in compliance with the License. You may obtain
4# a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11# License for the specific language governing permissions and limitations
12# under the License.
13
14from novaclient.tests.unit.fixture_data import client
15from novaclient.tests.unit.fixture_data import networks as data
16from novaclient.tests.unit import utils
17from novaclient.v2 import networks
18
19
20class NetworksTest(utils.FixturedTestCase):
21
22 client_fixture_class = client.V1
23 data_fixture_class = data.Fixture
24
25 def test_list_networks(self):
26 fl = self.cs.networks.list()
27 self.assert_called('GET', '/os-networks')
28 [self.assertIsInstance(f, networks.Network) for f in fl]
29
30 def test_get_network(self):
31 f = self.cs.networks.get(1)
32 self.assert_called('GET', '/os-networks/1')
33 self.assertIsInstance(f, networks.Network)
34
35 def test_delete(self):
36 self.cs.networks.delete('networkdelete')
37 self.assert_called('DELETE', '/os-networks/networkdelete')
38
39 def test_create(self):
40 f = self.cs.networks.create(label='foo')
41 self.assert_called('POST', '/os-networks',
42 {'network': {'label': 'foo'}})
43 self.assertIsInstance(f, networks.Network)
44
45 def test_create_allparams(self):
46 params = {
47 'label': 'bar',
48 'bridge': 'br0',
49 'bridge_interface': 'int0',
50 'cidr': '192.0.2.0/24',
51 'cidr_v6': '2001:DB8::/32',
52 'dns1': '1.1.1.1',
53 'dns2': '1.1.1.2',
54 'fixed_cidr': '198.51.100.0/24',
55 'gateway': '192.0.2.1',
56 'gateway_v6': '2001:DB8::1',
57 'multi_host': 'T',
58 'priority': '1',
59 'project_id': '1',
60 'vlan': 5,
61 'vlan_start': 1,
62 'vpn_start': 1,
63 'mtu': 1500,
64 'enable_dhcp': 'T',
65 'dhcp_server': '1920.2.2',
66 'share_address': 'T',
67 'allowed_start': '192.0.2.10',
68 'allowed_end': '192.0.2.20',
69 }
70
71 f = self.cs.networks.create(**params)
72 self.assert_called('POST', '/os-networks', {'network': params})
73 self.assertIsInstance(f, networks.Network)
74
75 def test_associate_project(self):
76 self.cs.networks.associate_project('networktest')
77 self.assert_called('POST', '/os-networks/add',
78 {'id': 'networktest'})
79
80 def test_associate_host(self):
81 self.cs.networks.associate_host('networktest', 'testHost')
82 self.assert_called('POST', '/os-networks/networktest/action',
83 {'associate_host': 'testHost'})
84
85 def test_disassociate(self):
86 self.cs.networks.disassociate('networkdisassociate')
87 self.assert_called('POST',
88 '/os-networks/networkdisassociate/action',
89 {'disassociate': None})
90
91 def test_disassociate_host_only(self):
92 self.cs.networks.disassociate('networkdisassociate', True, False)
93 self.assert_called('POST',
94 '/os-networks/networkdisassociate/action',
95 {'disassociate_host': None})
96
97 def test_disassociate_project(self):
98 self.cs.networks.disassociate('networkdisassociate', False, True)
99 self.assert_called('POST',
100 '/os-networks/networkdisassociate/action',
101 {'disassociate_project': None})
102
103 def test_add(self):
104 self.cs.networks.add('networkadd')
105 self.assert_called('POST', '/os-networks/add',
106 {'id': 'networkadd'})