Fix sudo errors in test__set_trunk_metadata_with_None_params

Mock out the entire bridge rather than set_db_attribute.

Change-Id: Ia6c112fc8aac1ec8a5397fcb80eedd0a430d2fbb
Closes-bug: #1622029
This commit is contained in:
Armando Migliaccio 2016-09-09 15:19:55 -07:00
parent 939e65b162
commit 493be3e11c

@ -182,13 +182,14 @@ class TestOVSDBHandler(base.BaseTestCase):
trunk_rpc.update_trunk_status.assert_called_once_with(
mock.ANY, mock.ANY, constants.ERROR_STATUS)
@mock.patch('neutron.agent.common.ovs_lib.OVSBridge.set_db_attribute')
def test__set_trunk_metadata_with_None_params(self, mock_f):
@mock.patch('neutron.agent.common.ovs_lib.OVSBridge')
def test__set_trunk_metadata_with_None_params(self, br):
mock_br = br.return_value
with mock.patch.object(
self.ovsdb_handler, "_get_parent_port",
return_value={'name': 'foo', 'external_ids': {}}):
self.ovsdb_handler._set_trunk_metadata(None, None, 'foo', [])
mock_f.assert_called_once_with(
mock_br.set_db_attribute.assert_called_once_with(
'Interface', 'foo', 'external_ids',
{'bridge_name': 'tbr-foo', 'trunk_id': 'foo',
{'bridge_name': mock.ANY, 'trunk_id': 'foo',
'subport_ids': '[]'})