neutron/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_capabilities.py
Isaku Yamahata 5a1934da8e unit test: unbreak test cases for callbacks.subscribe
patch set of [1] added callback priority so that a new argument, priority,
was added to subscribe method. Thus its signature was changed.
It caused to break some unit tests.[2] Those test cases check arguments passed
to subscribe method.

The fix to those test cases needs to be compatible with older version of
neutron-lib.
So add a helper method, get_subscribe_args, to produce argument to subscribe
by checking if neutron-lib supports callback priority or not. and apply it
to broken test cases.

[1] https://review.openstack.org/#/c/541766/
[2] http://logs.openstack.org/periodic/git.openstack.org/openstack/neutron/master/openstack-tox-py35-with-neutron-lib-master/66d328a/testr_results.html.gz
  test_capabilities.CapabilitiesTest.test_register
  test_ovs_capabilities.CapabilitiesTest.test_register
  test_backend.ServerSideRpcBackendTest.test___init__

Change-Id: I94066ff8a8dae5c5637478aa52883b3b451f2857
2018-04-11 07:20:42 +00:00

39 lines
1.4 KiB
Python

# Copyright 2016 Hewlett Packard Enterprise Development LP
#
# 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
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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_lib.callbacks import events
from neutron_lib import fixture
from neutron.plugins.ml2.drivers.openvswitch.agent import ovs_capabilities
from neutron.services.trunk.drivers.openvswitch.agent import driver
from neutron.tests import base
from neutron.tests import tools
from neutron_lib import constants
class CapabilitiesTest(base.BaseTestCase):
def setUp(self):
super(CapabilitiesTest, self).setUp()
self._mgr = mock.Mock()
self.useFixture(fixture.CallbackRegistryFixture(
callback_manager=self._mgr))
def test_register(self):
ovs_capabilities.register()
args = tools.get_subscribe_args(
driver.init_handler, constants.AGENT_TYPE_OVS, events.AFTER_INIT)
self._mgr.subscribe.assert_called_with(*args)