| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
from unittest import mock |
| 17 |
|
| 18 |
from neutron.api.rpc.callbacks.consumer import registry |
| 19 |
from neutron.api.rpc.callbacks import resources |
| 20 |
from neutron.api.rpc.handlers import resources_rpc |
| 21 |
from neutron.tests.unit.services.logapi.agent.l3 import test_base as base |
| 22 |
from neutron_lib import constants as lib_const |
| 23 |
|
| 24 |
from neutron_fwaas.services.logapi.agents.l3 import fwg_log |
| 25 |
|
| 26 |
|
| 27 |
class FWaaSL3LoggingExtensionInitializeTestCase(base.L3LoggingExtBaseTestCase): |
| 28 |
|
| 29 |
def setUp(self): |
| 30 |
super().setUp() |
| 31 |
self.fw_l3_log_ext = fwg_log.FWaaSL3LoggingExtension() |
| 32 |
self.fw_l3_log_ext.consume_api(self.agent_api) |
| 33 |
|
| 34 |
@mock.patch.object(registry, 'register') |
| 35 |
@mock.patch.object(resources_rpc, 'ResourcesPushRpcCallback') |
| 36 |
def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock): |
| 37 |
call_to_patch = 'neutron_lib.rpc.Connection' |
| 38 |
with mock.patch(call_to_patch, |
| 39 |
return_value=self.connection) as create_connection: |
| 40 |
self.fw_l3_log_ext.initialize( |
| 41 |
self.connection, lib_const.L3_AGENT_MODE) |
| 42 |
create_connection.assert_has_calls([mock.call()]) |
| 43 |
self.connection.create_consumer.assert_has_calls( |
| 44 |
[mock.call( |
| 45 |
resources_rpc.resource_type_versioned_topic( |
| 46 |
resources.LOGGING_RESOURCE), |
| 47 |
[rpc_mock()], |
| 48 |
fanout=True)] |
| 49 |
) |
| 50 |
subscribe_mock.assert_called_with( |
| 51 |
mock.ANY, resources.LOGGING_RESOURCE) |