You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.8 KiB

# Copyright 2013 Red Hat, Inc.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
from neutron.agent.common import base_polling
from neutron.agent.linux import polling
from neutron.agent.ovsdb.native import helpers
from neutron.tests import base
class TestGetPollingManager(base.BaseTestCase):
def setUp(self):
super(TestGetPollingManager, self).setUp()
mock.patch.object(helpers, 'enable_connection_uri').start()
def test_return_always_poll_by_default(self):
with polling.get_polling_manager() as pm:
self.assertEqual(pm.__class__, base_polling.AlwaysPoll)
def test_manage_polling_minimizer(self):
mock_target = 'neutron.agent.linux.polling.InterfacePollingMinimizer'
with mock.patch('%s.start' % mock_target) as mock_start:
with mock.patch('%s.stop' % mock_target) as mock_stop:
with polling.get_polling_manager(minimize_polling=True) as pm:
class TestInterfacePollingMinimizer(base.BaseTestCase):
def setUp(self):
super(TestInterfacePollingMinimizer, self).setUp()
mock.patch.object(helpers, 'enable_connection_uri').start() = polling.InterfacePollingMinimizer()
def test_start_calls_monitor_start(self):
with mock.patch.object(, 'start') as mock_start:
def test_stop_calls_monitor_stop(self):
with mock.patch.object(, 'stop') as mock_stop:
def mock_has_updates(self, return_value):
target = ('neutron.agent.linux.ovsdb_monitor.SimpleInterfaceMonitor'
return mock.patch(
def test__is_polling_required_returns_when_updates_are_present(self):
with self.mock_has_updates(True):