def setUp(self): cfg = ConfigParser() cfg.read('keystone.ini') auth_url = cfg.get(u'auth', u'auth_url') username = cfg.get(u'auth', u'username') password = cfg.get(u'auth', u'password') self.keystoneClientWorker = KeystoneClientWorker(auth_url, username=username, password=password)
#coding=utf-8 __author__ = 'cy-openstack' import unittest from configparser import ConfigParser from keystone.verify import KeystoneClientWorker from neutron.NeutronUtil import NeutronUtil cfg = ConfigParser() cfg.read('global.ini') auth_url = cfg.get(u'keystone', u'auth_url') auth_url = cfg.get(u'keystone', u'auth_url') username = cfg.get(u'keystone', u'username') password = cfg.get(u'keystone', u'password') keystoneClientWorker = KeystoneClientWorker(auth_url, username=username, password=password) token = keystoneClientWorker.getToken() class TestKeystone(unittest.TestCase): def setUp(self): self.keystoneClientWorker = keystoneClientWorker def tearDown(self): self.keystoneClientWorker = None def testGetToken(self): print u'验证在顶层文件产生额token是否为空' token = self.keystoneClientWorker.getToken() self.assertIsNotNone(token)