Debian Codegraph @

config_tempest/tests/services/test_ceilometer.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
17 from six.moves import configparser
18
19 from config_tempest.services import ceilometer
20 from config_tempest.tempest_conf import TempestConf
21 from config_tempest.tests.base import BaseServiceTest
22
23
24 class TestCeilometerService(BaseServiceTest):
25 def setUp(self):
26 super(TestCeilometerService, self).setUp()
27 self.Service = ceilometer.MeteringService("ServiceName",
28 "ServiceType",
29 self.FAKE_URL,
30 self.FAKE_TOKEN,
31 disable_ssl_validation=False)
32 self.conf = TempestConf()
33
34 def test_check_ceilometer_service(self):
35 client_service_mock = self.FakeServiceClient(services={})
36 self.Service.client = client_service_mock
37 self.Service.post_configuration(self.conf, client_service_mock)
38
39 self._assert_conf_get_not_raises(configparser.NoSectionError,
40 "service_available",
41 "ceilometer")
42
43 client_service_mock = self.FakeServiceClient(services={
44 'services': [
45 {
46 "name": "ceilometer",
47 "enabled": True
48 }
49 ]
50 })
51 self.Service.client = client_service_mock
52 self.Service.post_configuration(self.conf, client_service_mock)
53 self.Service.post_configuration(self.conf, client_service_mock)
54 self.assertEqual(self.conf.get('service_available', 'ceilometer'),
55 'True')