summaryrefslogtreecommitdiff
path: root/magnum/tests/unit/cmd/test_api.py
diff options
context:
space:
mode:
Diffstat (limited to 'magnum/tests/unit/cmd/test_api.py')
-rw-r--r--magnum/tests/unit/cmd/test_api.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/magnum/tests/unit/cmd/test_api.py b/magnum/tests/unit/cmd/test_api.py
index e6ce096..ea55ead 100644
--- a/magnum/tests/unit/cmd/test_api.py
+++ b/magnum/tests/unit/cmd/test_api.py
@@ -14,6 +14,8 @@
14 14
15import mock 15import mock
16 16
17from oslo_concurrency import processutils
18
17from magnum.cmd import api 19from magnum.cmd import api
18from magnum.tests import base 20from magnum.tests import base
19 21
@@ -32,9 +34,28 @@ class TestMagnumAPI(base.TestCase):
32 app = mock_app.load_app.return_value 34 app = mock_app.load_app.return_value
33 mock_prep.assert_called_once_with(mock.ANY) 35 mock_prep.assert_called_once_with(mock.ANY)
34 mock_app.load_app.assert_called_once_with() 36 mock_app.load_app.assert_called_once_with()
37 workers = processutils.get_worker_count()
38 mock_run.assert_called_once_with(base.CONF.api.host,
39 base.CONF.api.port,
40 app, processes=workers,
41 ssl_context=None)
42
43 @mock.patch('werkzeug.serving.run_simple')
44 @mock.patch.object(api, 'api_app')
45 @mock.patch('magnum.common.service.prepare_service')
46 def test_api_http_config_workers(self, mock_prep, mock_app,
47 mock_run, mock_base):
48 fake_workers = 8
49 self.config(workers=fake_workers, group='api')
50 api.main()
51
52 app = mock_app.load_app.return_value
53 mock_prep.assert_called_once_with(mock.ANY)
54 mock_app.load_app.assert_called_once_with()
35 mock_run.assert_called_once_with(base.CONF.api.host, 55 mock_run.assert_called_once_with(base.CONF.api.host,
36 base.CONF.api.port, 56 base.CONF.api.port,
37 app, ssl_context=None) 57 app, processes=fake_workers,
58 ssl_context=None)
38 59
39 @mock.patch('os.path.exists') 60 @mock.patch('os.path.exists')
40 @mock.patch('werkzeug.serving.run_simple') 61 @mock.patch('werkzeug.serving.run_simple')
@@ -91,6 +112,8 @@ class TestMagnumAPI(base.TestCase):
91 mock_app.load_app.assert_called_once_with() 112 mock_app.load_app.assert_called_once_with()
92 mock_exist.assert_has_calls([mock.call('tmp_crt'), 113 mock_exist.assert_has_calls([mock.call('tmp_crt'),
93 mock.call('tmp_key')]) 114 mock.call('tmp_key')])
115 workers = processutils.get_worker_count()
94 mock_run.assert_called_once_with(base.CONF.api.host, 116 mock_run.assert_called_once_with(base.CONF.api.host,
95 base.CONF.api.port, app, 117 base.CONF.api.port, app,
118 processes=workers,
96 ssl_context=('tmp_crt', 'tmp_key')) 119 ssl_context=('tmp_crt', 'tmp_key'))