cinder/cinder/tests/unit/conf_fixture.py
Victor Stinner d9b9ac893d Fix Python 3 issues in utils
* Replace string.split(key_file, ',') with key_file.split(','):
  the string.split() function was removed in Python 3, use the
  str.split() method instead
* Fix conf_fixture: import backup_enable_progress_timer and
  backup_swift_enable_progress_timer options. This change is required
  to run tests using testtools (it's now possible yet to run tests on
  Python 3 using testr).
* hash_file(): use b'' (bytes) for the sentinel, not '' (unicode), when
  reading the input binary file
* test_hash_file() requires a binary file (bytes), not a text file
  (unicode)
* Get the builtin open() function from six.moves.builtins instead of
  getting it from __builtin__ to mock the open() function. The
  __builtin__ module was renamed to builtins in Python 3.
* sanitize_hostname(): on Python 3, decode back the hostname from Latin1
  to work on a native string (Unicode)
* replace reduce() with six.moves.reduce(): the Python 2 builtin
  reduce() function was moved to the functools module in Python 3
* convert_version_to_str(): fix integer division, use a//b, not a/b
* convert_version_to_str(): replace reduce() with ''.join() with map(str)

Blueprint cinder-python3
Change-Id: If7b8f50c6a8b0a5044c2c7108b2b0293dddafff3
2015-06-15 10:29:22 +02:00

61 lines
2.6 KiB
Python

# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
from oslo_config import cfg
CONF = cfg.CONF
CONF.import_opt('backup_enable_progress_timer',
'cinder.backup.drivers.nfs')
CONF.import_opt('backup_swift_enable_progress_timer',
'cinder.backup.drivers.swift')
CONF.import_opt('policy_file', 'cinder.policy')
CONF.import_opt('volume_driver', 'cinder.volume.manager')
CONF.import_opt('xiv_ds8k_proxy',
'cinder.volume.drivers.ibm.xiv_ds8k')
CONF.import_opt('backup_driver', 'cinder.backup.manager')
CONF.import_opt('fixed_key', 'cinder.keymgr.conf_key_mgr', group='keymgr')
CONF.import_opt('scheduler_driver', 'cinder.scheduler.manager')
def_vol_type = 'fake_vol_type'
def set_defaults(conf):
conf.set_default('default_volume_type', def_vol_type)
conf.set_default('volume_driver',
'cinder.tests.unit.fake_driver.FakeISCSIDriver')
conf.set_default('iscsi_helper', 'fake')
conf.set_default('rpc_backend', 'cinder.openstack.common.rpc.impl_fake')
conf.set_default('connection', 'sqlite://', group='database')
conf.set_default('sqlite_synchronous', False, group='database')
conf.set_default('policy_file', 'cinder.tests.unit/policy.json')
conf.set_default(
'xiv_ds8k_proxy',
'cinder.tests.unit.test_ibm_xiv_ds8k.XIVDS8KFakeProxyDriver')
conf.set_default('backup_driver', 'cinder.tests.unit.backup.fake_service')
conf.set_default('fixed_key', default='0' * 64, group='keymgr')
conf.set_default('scheduler_driver',
'cinder.scheduler.filter_scheduler.FilterScheduler')
conf.set_default('state_path', os.path.abspath(
os.path.join(os.path.dirname(__file__), '..', '..', '..')))
conf.set_default('policy_dirs', [])
conf.set_default('auth_strategy', 'noauth')
conf.set_default('backup_enable_progress_timer', False)
conf.set_default('backup_swift_enable_progress_timer', False)