| 1 |
# Copyright (c) 2015 OpenStack Foundation. |
| 2 |
# All Rights Reserved. |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 |
# not use this file except in compliance with the License. You may obtain |
| 6 |
# a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 |
# License for the specific language governing permissions and limitations |
| 14 |
# under the License. |
| 15 |
|
| 16 |
from unittest import mock |
| 17 |
|
| 18 |
from neutron.tests import base |
| 19 |
|
| 20 |
from networking_l2gw.services.l2gateway.agent import agent_api |
| 21 |
|
| 22 |
|
| 23 |
class L2GatewayAgentApiTestCase(base.BaseTestCase): |
| 24 |
|
| 25 |
def setUp(self): |
| 26 |
self.client_mock_p = mock.patch.object(agent_api.n_rpc, 'get_client') |
| 27 |
self.client_mock = self.client_mock_p.start() |
| 28 |
self.topic = 'foo_topic' |
| 29 |
self.host = 'foo_host' |
| 30 |
|
| 31 |
self.agent_rpc = agent_api.L2GatewayAgentApi( |
| 32 |
self.topic, self.host) |
| 33 |
super().setUp() |
| 34 |
|
| 35 |
def test_update_ovsdb_changes(self): |
| 36 |
cctxt = mock.Mock() |
| 37 |
context = mock.Mock() |
| 38 |
fake_activity = 1 |
| 39 |
self.agent_rpc.client.prepare.return_value = cctxt |
| 40 |
self.agent_rpc.update_ovsdb_changes(context, fake_activity, mock.ANY) |
| 41 |
cctxt.cast.assert_called_with( |
| 42 |
context, 'update_ovsdb_changes', |
| 43 |
activity=fake_activity, ovsdb_data=mock.ANY) |
| 44 |
|
| 45 |
def test_notify_ovsdb_states(self): |
| 46 |
cctxt = mock.Mock() |
| 47 |
context = mock.Mock() |
| 48 |
self.agent_rpc.client.prepare.return_value = cctxt |
| 49 |
self.agent_rpc.notify_ovsdb_states(context, mock.ANY) |
| 50 |
cctxt.cast.assert_called_with( |
| 51 |
context, 'notify_ovsdb_states', ovsdb_states=mock.ANY) |