summaryrefslogtreecommitdiff
path: root/shade/tests/unit/test_router.py
diff options
context:
space:
mode:
Diffstat (limited to 'shade/tests/unit/test_router.py')
-rw-r--r--shade/tests/unit/test_router.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/shade/tests/unit/test_router.py b/shade/tests/unit/test_router.py
index f969b90..ee5f20f 100644
--- a/shade/tests/unit/test_router.py
+++ b/shade/tests/unit/test_router.py
@@ -14,6 +14,7 @@
14# limitations under the License. 14# limitations under the License.
15 15
16import copy 16import copy
17import testtools
17 18
18from shade import exc 19from shade import exc
19from shade.tests.unit import base 20from shade.tests.unit import base
@@ -52,6 +53,16 @@ class TestRouter(base.RequestsMockTestCase):
52 'request_ids': ['req-f1b0b1b4-ae51-4ef9-b371-0cc3c3402cf7'] 53 'request_ids': ['req-f1b0b1b4-ae51-4ef9-b371-0cc3c3402cf7']
53 } 54 }
54 55
56 router_availability_zone_extension = {
57 "alias": "router_availability_zone",
58 "updated": "2015-01-01T10:00:00-00:00",
59 "description": "Availability zone support for router.",
60 "links": [],
61 "name": "Router Availability Zone"
62 }
63
64 enabled_neutron_extensions = [router_availability_zone_extension]
65
55 def test_get_router(self): 66 def test_get_router(self):
56 self.register_uris([ 67 self.register_uris([
57 dict(method='GET', 68 dict(method='GET',
@@ -112,6 +123,27 @@ class TestRouter(base.RequestsMockTestCase):
112 project_id=new_router_tenant_id) 123 project_id=new_router_tenant_id)
113 self.assert_calls() 124 self.assert_calls()
114 125
126 def test_create_router_with_availability_zone_hints(self):
127 self.register_uris([
128 dict(method='GET',
129 uri=self.get_mock_url(
130 'network', 'public', append=['v2.0', 'extensions.json']),
131 json={'extensions': self.enabled_neutron_extensions}),
132 dict(method='POST',
133 uri=self.get_mock_url(
134 'network', 'public', append=['v2.0', 'routers.json']),
135 json={'router': self.mock_router_rep},
136 validate=dict(
137 json={'router': {
138 'name': self.router_name,
139 'admin_state_up': True,
140 'availability_zone_hints': ['nova']}}))
141 ])
142 self.cloud.create_router(
143 name=self.router_name, admin_state_up=True,
144 availability_zone_hints=['nova'])
145 self.assert_calls()
146
115 def test_create_router_with_enable_snat_True(self): 147 def test_create_router_with_enable_snat_True(self):
116 """Do not send enable_snat when same as neutron default.""" 148 """Do not send enable_snat when same as neutron default."""
117 self.register_uris([ 149 self.register_uris([
@@ -145,6 +177,16 @@ class TestRouter(base.RequestsMockTestCase):
145 name=self.router_name, admin_state_up=True, enable_snat=False) 177 name=self.router_name, admin_state_up=True, enable_snat=False)
146 self.assert_calls() 178 self.assert_calls()
147 179
180 def test_create_router_wrong_availability_zone_hints_type(self):
181 azh_opts = "invalid"
182 with testtools.ExpectedException(
183 exc.OpenStackCloudException,
184 "Parameter 'availability_zone_hints' must be a list"
185 ):
186 self.cloud.create_router(
187 name=self.router_name, admin_state_up=True,
188 availability_zone_hints=azh_opts)
189
148 def test_add_router_interface(self): 190 def test_add_router_interface(self):
149 self.register_uris([ 191 self.register_uris([
150 dict(method='PUT', 192 dict(method='PUT',