Debian Codegraph @

config_tempest/tests/services/test_compute.py

raw symbols SCIP
1 # Copyright 2018 Red Hat, 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
16 from unittest import mock
17
18 from config_tempest.services.compute import ComputeService
19 from config_tempest.tempest_conf import TempestConf
20 from config_tempest.tests.base import BaseServiceTest
21
22
23 class TestComputeService(BaseServiceTest):
24 def setUp(self):
25 super(TestComputeService, self).setUp()
26 self.Service = ComputeService("ServiceName",
27 "ServiceType",
28 self.FAKE_URL,
29 self.FAKE_TOKEN,
30 disable_ssl_validation=False)
31
32 def test_set_get_extensions(self):
33 exp_resp = []
34 self._set_get_extensions(self.Service, exp_resp, self.FAKE_EXTENSIONS)
35
36 def test_set_get_versions(self):
37 exp_resp = ['v2.0', 'v2.1']
38 self._set_get_versions(self.Service, exp_resp, self.FAKE_VERSIONS)
39
40 @mock.patch('config_tempest.services.compute'
41 '.ComputeService._get_number_of_hosts')
42 def test_set_default_tempest_options(self, mock_get_number_of_hosts):
43 mock_get_number_of_hosts.return_value = 2
44 conf = TempestConf()
45 self.Service.set_default_tempest_options(conf)
46 self.assertEqual(
47 conf.get('compute',
48 'min_compute_nodes'), '2')
49 self.assertEqual(
50 conf.get('compute-feature-enabled',
51 'resize'), 'True')
52 self.assertEqual(
53 conf.get('compute-feature-enabled',
54 'console_output'), 'True')
55 mock_get_number_of_hosts.assert_called_once()