def init(name_config=None, debug=None): try: cfglib.init_config(name_config) except oslo_config.cfg.Error: traceback.print_exc() sys.exit(ERROR_INVALID_CONFIGURATION) utils.init_singletones(cfglib.CONF) if cfglib.CONF.migrate.hide_ssl_warnings: warnings.simplefilter("ignore") if debug is not None: value = oslo_config.types.Boolean()(debug) cfglib.CONF.set_override('debug', value, 'migrate') log.configure_logging()
def __init__(self, *args, **kwargs): super(TestCase, self).__init__(*args, **kwargs) self.cfg = cfglib.CONF cfglib.init_config()
def init_config(self, config_path): conf = cfglib.init_config(config_path) if self.app.options.debug: conf.set_override('debug', self.app.options.debug, 'migrate') return conf
def setUp(self): super(KeystoneIdentityTestCase, self).setUp() self.mock_client = mock.MagicMock() self.kc_patch = mockpatch.PatchObject(keystone_client, 'Client', new=self.mock_client) self.useFixture(self.kc_patch) self.fake_cloud = mock.Mock() self.fake_cloud.mysql_connector = mock.Mock() self.keystone_client = keystone.KeystoneIdentity(FAKE_CONFIG, self.fake_cloud) self.fake_tenant_0 = mock.Mock(spec=keystone_client.tenants.Tenant) self.fake_tenant_0.name = 'tenant_name_0' self.fake_tenant_0.description = 'tenant_description_0' self.fake_tenant_0.id = 'tenant_id_0' self.fake_tenant_1 = mock.Mock(spec=keystone_client.tenants.Tenant) self.fake_tenant_1.name = 'tenant_name_1' self.fake_tenant_1.description = 'tenant_description_1' self.fake_tenant_1.id = 'tenant_id_1' self.fake_user_0 = mock.Mock(spec=keystone_client.users.User) self.fake_user_0.name = 'user_name_0' self.fake_user_0.id = 'user_id_0' self.fake_user_0.tenantId = self.fake_tenant_0.id self.fake_user_0.email = '*****@*****.**' self.fake_user_1 = mock.Mock(spec=keystone_client.users.User) self.fake_user_1.name = 'user_name_1' self.fake_user_1.id = 'user_id_1' self.fake_user_1.tenantId = self.fake_tenant_1.id self.fake_user_1.email = '*****@*****.**' self.fake_role_0 = mock.Mock(spec=keystone_client.roles.Role) self.fake_role_0.name = 'role_name_0' self.fake_role_0.id = 'role_id_0' self.fake_role_1 = mock.Mock(spec=keystone_client.roles.Role) self.fake_role_1.name = 'role_name_1' self.fake_role_1.id = 'role_id_1' cfglib.init_config() cfglib.CONF.src.user = '******' cfglib.CONF.dst.user = '******' self.fake_src_admin_user = mock.Mock() self.fake_src_admin_user.name = 'src_admin_user' self.fake_dst_admin_user = mock.Mock() self.fake_dst_admin_user.name = 'dst_admin_user' self.fake_same_user = mock.Mock() self.fake_same_user.id = 'fake_same_id' self.fake_same_user.name = 'fake_same_name' src_keystone = mock.Mock() dst_keystone = mock.Mock() self.fake_src_keystone = src_keystone self.fake_dst_keystone = dst_keystone src_keystone.keystone_client.users.list.return_value = [ self.fake_user_0, self.fake_same_user, self.fake_src_admin_user] dst_keystone.keystone_client.users.list.return_value = [ self.fake_user_1, self.fake_same_user, self.fake_dst_admin_user] src_keystone.keystone_client.users.get.side_effect = self.mock_user_get dst_keystone.keystone_client.users.get.side_effect = self.mock_user_get src_keystone.try_get_user_by_name.side_effect = self.mock_user_get dst_keystone.try_get_user_by_name.side_effect = self.mock_user_get