Coverage for manila/tests/test_rpc.py: 100%
19 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
1# Copyright 2017 Red Hat, Inc.
2# Licensed under the Apache License, Version 2.0 (the "License"); you may
3# not use this file except in compliance with the License. You may obtain
4# a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11# License for the specific language governing permissions and limitations
12# under the License.
14from unittest import mock
16import ddt
18from manila import rpc
19from manila import test
22@ddt.ddt
23class RPCTestCase(test.TestCase):
25 @ddt.data([], ['noop'], ['noop', 'noop'])
26 @mock.patch('oslo_messaging.JsonPayloadSerializer', wraps=True)
27 def test_init_no_notifications(self, driver, serializer_mock):
28 self.override_config('driver', driver,
29 group='oslo_messaging_notifications')
30 rpc.init(test.CONF)
31 self.assertEqual(rpc.utils.DO_NOTHING, rpc.NOTIFIER)
32 serializer_mock.assert_not_called()
34 @mock.patch.object(rpc, 'messaging')
35 def test_init_notifications(self, messaging_mock):
36 rpc.init(test.CONF)
37 self.assertTrue(messaging_mock.JsonPayloadSerializer.called)
38 self.assertTrue(messaging_mock.Notifier.called)
39 self.assertEqual(rpc.NOTIFIER, messaging_mock.Notifier.return_value)