summaryrefslogtreecommitdiff
path: root/shade/tests/unit/test_network.py
diff options
context:
space:
mode:
Diffstat (limited to 'shade/tests/unit/test_network.py')
-rw-r--r--shade/tests/unit/test_network.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/shade/tests/unit/test_network.py b/shade/tests/unit/test_network.py
index 96af721..bf7275d 100644
--- a/shade/tests/unit/test_network.py
+++ b/shade/tests/unit/test_network.py
@@ -47,6 +47,16 @@ class TestNetwork(base.RequestsMockTestCase):
47 'mtu': 0 47 'mtu': 0
48 } 48 }
49 49
50 network_availability_zone_extension = {
51 "alias": "network_availability_zone",
52 "updated": "2015-01-01T10:00:00-00:00",
53 "description": "Availability zone support for router.",
54 "links": [],
55 "name": "Network Availability Zone"
56 }
57
58 enabled_neutron_extensions = [network_availability_zone_extension]
59
50 def test_list_networks(self): 60 def test_list_networks(self):
51 net1 = {'id': '1', 'name': 'net1'} 61 net1 = {'id': '1', 'name': 'net1'}
52 net2 = {'id': '2', 'name': 'net2'} 62 net2 = {'id': '2', 'name': 'net2'}
@@ -151,6 +161,27 @@ class TestNetwork(base.RequestsMockTestCase):
151 self.assertEqual(mock_new_network_rep, network) 161 self.assertEqual(mock_new_network_rep, network)
152 self.assert_calls() 162 self.assert_calls()
153 163
164 def test_create_network_with_availability_zone_hints(self):
165 self.register_uris([
166 dict(method='GET',
167 uri=self.get_mock_url(
168 'network', 'public', append=['v2.0', 'extensions.json']),
169 json={'extensions': self.enabled_neutron_extensions}),
170 dict(method='POST',
171 uri=self.get_mock_url(
172 'network', 'public', append=['v2.0', 'networks.json']),
173 json={'network': self.mock_new_network_rep},
174 validate=dict(
175 json={'network': {
176 'admin_state_up': True,
177 'name': 'netname',
178 'availability_zone_hints': ['nova']}}))
179 ])
180 network = self.cloud.create_network("netname",
181 availability_zone_hints=['nova'])
182 self.assertEqual(self.mock_new_network_rep, network)
183 self.assert_calls()
184
154 def test_create_network_provider_ignored_value(self): 185 def test_create_network_provider_ignored_value(self):
155 provider_opts = {'physical_network': 'mynet', 186 provider_opts = {'physical_network': 'mynet',
156 'network_type': 'vlan', 187 'network_type': 'vlan',
@@ -180,6 +211,15 @@ class TestNetwork(base.RequestsMockTestCase):
180 self.assertEqual(mock_new_network_rep, network) 211 self.assertEqual(mock_new_network_rep, network)
181 self.assert_calls() 212 self.assert_calls()
182 213
214 def test_create_network_wrong_availability_zone_hints_type(self):
215 azh_opts = "invalid"
216 with testtools.ExpectedException(
217 shade.OpenStackCloudException,
218 "Parameter 'availability_zone_hints' must be a list"
219 ):
220 self.cloud.create_network("netname",
221 availability_zone_hints=azh_opts)
222
183 def test_create_network_provider_wrong_type(self): 223 def test_create_network_provider_wrong_type(self):
184 provider_opts = "invalid" 224 provider_opts = "invalid"
185 with testtools.ExpectedException( 225 with testtools.ExpectedException(