3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
17 from neutron.api.rpc.handlers import securitygroups_rpc
18 from neutron.tests import base
21 class SecurityGroupServerRpcApiTestCase(base.BaseTestCase):
23 def test_security_group_rules_for_devices(self):
24 rpcapi = securitygroups_rpc.SecurityGroupServerRpcApi('fake_topic')
26 with mock.patch.object(rpcapi.client, 'call') as rpc_mock,\
27 mock.patch.object(rpcapi.client, 'prepare') as prepare_mock:
28 prepare_mock.return_value = rpcapi.client
29 rpcapi.security_group_rules_for_devices('context', ['fake_device'])
31 rpc_mock.assert_called_once_with(
33 'security_group_rules_for_devices',
34 devices=['fake_device'])
37 class SGAgentRpcCallBackMixinTestCase(base.BaseTestCase):
40 super(SGAgentRpcCallBackMixinTestCase, self).setUp()
41 self.rpc = securitygroups_rpc.SecurityGroupAgentRpcCallbackMixin()
42 self.rpc.sg_agent = mock.Mock()
44 def test_security_groups_rule_updated(self):
45 self.rpc.security_groups_rule_updated(None,
46 security_groups=['fake_sgid'])
47 self.rpc.sg_agent.assert_has_calls(
48 [mock.call.security_groups_rule_updated(['fake_sgid'])])
50 def test_security_groups_member_updated(self):
51 self.rpc.security_groups_member_updated(None,
52 security_groups=['fake_sgid'])
53 self.rpc.sg_agent.assert_has_calls(
54 [mock.call.security_groups_member_updated(['fake_sgid'])])
56 def test_security_groups_provider_updated(self):
57 self.rpc.security_groups_provider_updated(None)
58 self.rpc.sg_agent.assert_has_calls(
59 [mock.call.security_groups_provider_updated(None)])