cue/tests/integration/common/config.py
Steve Leon b1646e5112 Adding base for integration tests
- Added sample tests for list/create/get clusters

Change-Id: If3b6af5c58579ec0e94d16570a626d3a05dddce9
2015-05-01 15:30:05 -07:00

64 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2015 Hewlett-Packard Development Company, L.P.
#
# 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
TEST_CONF = None
def setup_config(config_file=''):
global TEST_CONF
TEST_CONF = cfg.ConfigOpts()
identity_group = cfg.OptGroup(name='identity')
identity_options = [
cfg.StrOpt('uri', default='http://localhost:5000/v2.0'),
cfg.StrOpt('username', default='demo'),
cfg.StrOpt('password', default='secret'),
cfg.StrOpt('tenant_name', default='demo'),
]
TEST_CONF.register_group(identity_group)
TEST_CONF.register_opts(identity_options, group=identity_group)
message_queue_group = cfg.OptGroup(name='message_queue')
message_queue_options = [
cfg.StrOpt('flavor', default='8795'),
]
TEST_CONF.register_group(message_queue_group)
TEST_CONF.register_opts(message_queue_options, group=message_queue_group)
# Figure out which config to load
config_to_load = []
local_config = 'cue-integration.conf'
if os.path.isfile(config_file):
config_to_load.append(config_file)
elif os.path.isfile(local_config):
config_to_load.append(local_config)
else:
config_to_load.append('/etc/cue/cue-integration.conf')
# Actually parse config
TEST_CONF(
(), # Required to load a anonymous config
default_config_files=config_to_load
)
def get_config():
if not TEST_CONF:
setup_config()
return TEST_CONF