Debian Codegraph @

neutron_fwaas/tests/unit/services/logapi/agents/l3/test_fwg_log.py

raw symbols SCIP
1 # Copyright (c) 2018 Fujitsu Limited.
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.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)