1
# Copyright (c) 2015 Openstack Foundation
3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
# not use this file except in compliance with the License. You may obtain
5
# a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
# License for the specific language governing permissions and limitations
17
from neutron.agent.l3 import ha_router
18
from neutron.openstack.common import uuidutils
19
from neutron.tests import base
21
_uuid = uuidutils.generate_uuid
24
class TestBasicRouterOperations(base.BaseTestCase):
26
super(TestBasicRouterOperations, self).setUp()
28
def _create_router(self, router=None, **kwargs):
30
router = mock.MagicMock()
31
self.agent_conf = mock.Mock()
32
# NOTE The use_namespaces config will soon be deprecated
33
self.agent_conf.use_namespaces = True
34
self.router_id = _uuid()
35
return ha_router.HaRouter(self.router_id,
41
def test_get_router_cidrs_returns_ha_cidrs(self):
42
ri = self._create_router()
43
device = mock.MagicMock()
44
device.name.return_value = 'eth2'
45
addresses = ['15.1.2.2/24', '15.1.2.3/32']
46
ri._ha_get_existing_cidrs = mock.MagicMock(return_value=addresses)
47
self.assertEqual(set(addresses), ri.get_router_cidrs(device))