Debian Codegraph @

neutron_fwaas/tests/unit/services/logapi/rpc/test_log_server.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.services.logapi.rpc import server as server_rpc
19 from neutron.tests import base
20
21 from neutron_fwaas.services.logapi.rpc import log_server as fw_server_rpc
22
23
24 class FWGLoggingApiSkeletonTestCase(base.BaseTestCase):
25 @mock.patch("neutron_fwaas.services.logapi.common.log_db_api."
26 "get_fwg_log_info_for_port")
27 def test_get_fwg_log_info_for_port(self, mock_callback):
28 with mock.patch.object(
29 server_rpc,
30 'get_rpc_method',
31 return_value=fw_server_rpc.get_fwg_log_info_for_port
32 ):
33 test_obj = server_rpc.LoggingApiSkeleton()
34 m_context = mock.Mock()
35 port_id = '123'
36 test_obj.get_sg_log_info_for_port(m_context,
37 resource_type='firewall_v2',
38 port_id=port_id)
39 mock_callback.assert_called_with(m_context, port_id)
40
41 @mock.patch("neutron_fwaas.services.logapi.common.log_db_api."
42 "get_fwg_log_info_for_log_resources")
43 def test_get_fwg_log_info_for_log_resources(self, mock_callback):
44 with mock.patch.object(
45 server_rpc,
46 'get_rpc_method',
47 return_value=fw_server_rpc.get_fwg_log_info_for_log_resources
48 ):
49 test_obj = server_rpc.LoggingApiSkeleton()
50 m_context = mock.Mock()
51 log_resources = [mock.Mock()]
52 test_obj.get_sg_log_info_for_log_resources(
53 m_context,
54 resource_type='firewall_v2',
55 log_resources=log_resources)
56 mock_callback.assert_called_with(m_context, log_resources)