Coverage for manila/tests/wsgi/test_wsgi.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Copyright 2017 Mirantis Inc. 

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 

16from unittest import mock 

17 

18from manila import test 

19from manila.wsgi import wsgi 

20 

21 

22class WSGITestCase(test.TestCase): 

23 

24 def test_initialize_application(self): 

25 self.mock_object(wsgi.logging, 'register_options') 

26 self.mock_object(wsgi.cfg.ConfigOpts, '__call__') 

27 self.mock_object(wsgi.config, 'verify_share_protocols') 

28 self.mock_object(wsgi.logging, 'setup') 

29 self.mock_object(wsgi.rpc, 'init') 

30 self.mock_object(wsgi.wsgi, 'Loader') 

31 wsgi.sys.argv = ['--verbose', '--debug'] 

32 

33 result = wsgi.initialize_application() 

34 

35 self.assertEqual( 

36 wsgi.wsgi.Loader.return_value.load_app.return_value, result) 

37 wsgi.logging.register_options.assert_called_once_with(mock.ANY) 

38 wsgi.cfg.ConfigOpts.__call__.assert_called_once_with( 

39 mock.ANY, project="manila", version=wsgi.version.version_string()) 

40 wsgi.config.verify_share_protocols.assert_called_once_with() 

41 wsgi.logging.setup.assert_called_once_with(mock.ANY, "manila") 

42 wsgi.rpc.init.assert_called_once_with(mock.ANY) 

43 wsgi.wsgi.Loader.assert_called_once_with(mock.ANY) 

44 wsgi.wsgi.Loader.return_value.load_app.assert_called_once_with( 

45 name='osapi_share')