"Fossies" - the Fresh Open Source Software Archive

Member "keystone-19.0.0/keystone/tests/unit/test_config.py" (14 Apr 2021, 2693 Bytes) of package /linux/misc/openstack/keystone-19.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "test_config.py": 18.0.0_vs_19.0.0.

    1 # Copyright 2013 OpenStack Foundation
    2 #
    3 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    4 #    not use this file except in compliance with the License. You may obtain
    5 #    a copy of the License at
    6 #
    7 #         http://www.apache.org/licenses/LICENSE-2.0
    8 #
    9 #    Unless required by applicable law or agreed to in writing, software
   10 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   11 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   12 #    License for the specific language governing permissions and limitations
   13 #    under the License.
   14 
   15 import os
   16 
   17 from oslo_config import generator
   18 
   19 import keystone.conf
   20 from keystone.tests import unit
   21 
   22 
   23 CONF = keystone.conf.CONF
   24 
   25 
   26 class ConfigTestCase(unit.TestCase):
   27 
   28     def config_files(self):
   29         config_files = super(ConfigTestCase, self).config_files()
   30 
   31         sample_file = 'keystone.conf.sample'
   32         args = ['--namespace', 'keystone', '--output-file',
   33                 unit.dirs.etc(sample_file)]
   34         generator.main(args=args)
   35         config_files.insert(0, unit.dirs.etc(sample_file))
   36         self.addCleanup(os.remove, unit.dirs.etc(sample_file))
   37         return config_files
   38 
   39     def test_config_default(self):
   40         self.assertIsNone(CONF.auth.password)
   41         self.assertIsNone(CONF.auth.token)
   42         # Check config.set_config_defaults() has set [profiler]enabled.
   43         self.assertEqual(False, CONF.profiler.enabled)
   44 
   45 
   46 class DeprecatedTestCase(unit.TestCase):
   47     """Test using the original (deprecated) name for renamed options."""
   48 
   49     def config_files(self):
   50         config_files = super(DeprecatedTestCase, self).config_files()
   51         config_files.append(unit.dirs.tests_conf('deprecated.conf'))
   52         return config_files
   53 
   54     def test_sql(self):
   55         # Options in [sql] were moved to [database] in Icehouse for the change
   56         # to use oslo-incubator's db.sqlalchemy.sessions.
   57 
   58         self.assertEqual('sqlite://deprecated', CONF.database.connection)
   59         self.assertEqual(54321, CONF.database.idle_timeout)
   60 
   61 
   62 class DeprecatedOverrideTestCase(unit.TestCase):
   63     """Test using the deprecated AND new name for renamed options."""
   64 
   65     def config_files(self):
   66         config_files = super(DeprecatedOverrideTestCase, self).config_files()
   67         config_files.append(unit.dirs.tests_conf('deprecated_override.conf'))
   68         return config_files
   69 
   70     def test_sql(self):
   71         # Options in [sql] were moved to [database] in Icehouse for the change
   72         # to use oslo-incubator's db.sqlalchemy.sessions.
   73 
   74         self.assertEqual('sqlite://new', CONF.database.connection)
   75         self.assertEqual(65432, CONF.database.idle_timeout)