def test_CreateProfile_NoRequired(self): ''' @summary: 分为三种情况,1)缺少名称 2)缺少网络id 3)提供网络名称而非网络id @note: 操作失败,验证返回状态码和报错信息 ''' self.expected_result_index = 0 self.proapi = ProfilesAPIs() @BaseTestCase.drive_data(self, self.dm.profile_info) def do_test(xml_info): self.flag = True LogPrint().info("Test: Create a profile for network %s."%self.dm.nw_name) r = self.proapi.createProfiles(xml_info) if r['status_code']==self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info_list[self.expected_result_index]), r['result']): LogPrint().info("PASS: The returned status code and messages are CORRECT.") else: LogPrint().error("FAIL: The returned messages are INCORRECT.") self.flag = False else: LogPrint().error("FAIL: The returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code)) self.flag = False self.assertTrue(self.flag) self.expected_result_index += 1 do_test()
def setUp(self): self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC."%self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] self.proapi = ProfilesAPIs() LogPrint().info("Pre-Test-2: Create a profile %s for this network."%self.dm.profile_name) self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
def setUp(self): ''' @summary: 初始化测试数据、测试环境。 ''' # 初始化测试数据 self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a new network '%s'." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] #为该网络创建多个配置集 LogPrint().info("Pre-Test-2: Create multi-profiles for network '%s'." % self.dm.nw_name) self.proapi = ProfilesAPIs() self.proapi.createProfiles(self.dm.profile_info,self.nw_id)
def test_GetProfileList(self): ''' @summary: 获取系统配置集列表 @note: 操作成功,验证返回状态码 ''' self.proapi = ProfilesAPIs() LogPrint().info("Test: Get profile list.") r = self.proapi.getProfilesList() if r['status_code'] == 200: LogPrint().info('PASS: Get profile list SUCCESS.') self.flag = True else: LogPrint().error('FAIL: Returned status code is WRONG.') self.flag = False self.assertTrue(self.flag)
class ITC060202_GetNetworkProfileInfo(BaseTestCase): ''' @summary: ITC-06网络管理-02配置集管理-02获取配置集详情 ''' def setUp(self): ''' @summary: 初始化测试数据、测试环境。 ''' # 初始化测试数据 self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a new network '%s'." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] #为该网络创建多个配置集 LogPrint().info("Pre-Test-2: Create multi-profiles for network '%s'." % self.dm.nw_name) self.proapi = ProfilesAPIs() self.proapi.createProfiles(self.dm.profile_info,self.nw_id) def test_GetNetworkProfileInfo(self): ''' @summary: 获取网络的配置集信息 @note: 操作成功,验证返回码和接口信息 ''' self.nwproapi = NetworkProfilesAPIs() LogPrint().info("Test: Get network %s's profile %s info." % (self.dm.nw_name, self.dm.profile_name)) r = self.nwproapi.getNetworkProfileInfo(self.nw_id, self.dm.profile_name) if r['status_code']==self.dm.expected_status_code: dict_actual = r['result'] dict_expected = xmltodict.parse((self.dm.profile_info %self.nw_id)) dictCompare = DictCompare() if dictCompare.isSubsetDict(dict_expected, dict_actual): LogPrint().info("PASS: Get network %s's profile %s info SUCCESS." % (self.dm.nw_name, self.dm.profile_name) ) self.flag = True else: LogPrint().error("FAIL: Returned messages are INCORRECT.") self.flag = False else: LogPrint().error("FAIL: Get NetworkProfile Info FAILED. Returned status code '%s' is WRONG." % r['status_code'] ) self.flag = False self.assertTrue(self.flag) def tearDown(self): ''' @summary: 清除该网络及配置集 ''' LogPrint().info("Post-Test: Delete network '%s' and it's profiles." % self.dm.nw_name) self.assertTrue(smart_delete_network(self.dm.nw_name,self.dm.dc_name))
def test_CreateProfile_NoRequired(self): """ @summary: 分为三种情况,1)缺少名称 2)缺少网络id 3)提供网络名称而非网络id @note: 操作失败,验证返回状态码和报错信息 """ self.expected_result_index = 0 self.proapi = ProfilesAPIs() @BaseTestCase.drive_data(self, self.dm.profile_info) def do_test(xml_info): self.flag = True LogPrint().info("Test: Create a profile for network %s." % self.dm.nw_name) r = self.proapi.createProfiles(xml_info) if r["status_code"] == self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict( xmltodict.parse(self.dm.expected_info_list[self.expected_result_index]), r["result"] ): LogPrint().info("PASS: The returned status code and messages are CORRECT.") else: LogPrint().error("FAIL: The returned messages are INCORRECT.") self.flag = False else: LogPrint().error( "FAIL: The returned status code is '%s' while it should be '%s'." % (r["status_code"], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag) self.expected_result_index += 1 do_test()
def test_CreateProfile(self): """ @summary: 创建配置集 @note: 操作成功,验证返回状态码,验证接口返回信息 """ self.flag = True self.proapi = ProfilesAPIs() LogPrint().info("Test: Create a profile %s for network %s." % (self.dm.profile_name, self.dm.nw_name)) r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id) if r["status_code"] == self.dm.expected_status_code: dict_actual = r["result"] dict_expected = xmltodict.parse((self.dm.profile_info % self.nw_id)) dictCompare = DictCompare() if dictCompare.isSubsetDict(dict_expected, dict_actual): LogPrint().info( "PASS: Create profile %s for network %s SUCCESS." % (self.dm.profile_name, self.dm.nw_name) ) # return True else: LogPrint().error("FAIL:Returned Profile info INCORRECT.") self.flag = False else: LogPrint().error( "FAIL: Returned status code is %s not %s. " % (r["status_code"], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag)
def setUp(self): self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() # 首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"] self.proapi = ProfilesAPIs() LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name) self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
class ITC060201_GetNetworkProfileList(BaseTestCase): ''' @summary: ITC-06网络管理-02配置集管理-01获取配置集列表 ''' def setUp(self): ''' @summary: 初始化测试数据、测试环境。 ''' self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a new network '%s'." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] #为该网络创建多个配置集 LogPrint().info("Pre-Test-2: Create multi-profiles for network '%s'." % self.dm.nw_name) self.proapi = ProfilesAPIs() @BaseTestCase.drive_data(self, self.dm.profile_info) def do_test(xml_info): self.proapi.createProfiles(xml_info,self.nw_id) do_test() def test_GetNetworkProfileList(self): ''' @summary: 获取网络的配置集列表 ''' self.nwproapi = NetworkProfilesAPIs() LogPrint().info("Test: To get all NetworkProfiles list.") r = self.nwproapi.getNetworkProfileList(self.nw_id) if r['status_code']==self.dm.expected_status_code: LogPrint().info('PASS: Get NetworkProfile list SUCCESS.') self.flag = True else: LogPrint().error('FAIL: Get Network Profile list FAIL. Returned status code "%s" is WRONG.' % r['status_code']) self.flag = False self.assertTrue(self.flag) def tearDown(self): ''' @summary: 清除该网络及配置集 ''' LogPrint().info("Post-Test: Delete network '%s' and it's profiles." % self.dm.nw_name) self.assertTrue(smart_delete_network(self.dm.nw_name,self.dm.dc_name))
class ITC090401_UpdateProfile(BaseTestCase): """ @summary: ITC-06配置集管理-04编辑配置集-01成功编辑 """ def setUp(self): self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() # 首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"] self.proapi = ProfilesAPIs() LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name) self.proapi.createProfiles(self.dm.profile_info, self.nw_id) def test_UpdateProfile(self): """ @summary: 编辑配置集 @note: 操作成功,验证返回状态码,验证接口返回信息 """ self.flag = True LogPrint().info("Test: Update profile %s of network %s." % (self.dm.profile_name, self.dm.nw_name)) r = self.proapi.updateProfile(self.dm.profile_name, self.nw_id, self.dm.update_info) if r["status_code"] == self.dm.expected_status_code: dict_actual = r["result"] dict_expected = xmltodict.parse(self.dm.update_info) dictCompare = DictCompare() if dictCompare.isSubsetDict(dict_expected, dict_actual): LogPrint().info("PASS: Update Profile info SUCCESS.") else: LogPrint().error("FAIL: Update Profile info INCORRECT.") self.flag = False else: LogPrint().error( "FAIL: The returned status code is '%s' while it should be '%s'." % (r["status_code"], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag) def tearDown(self): # 删除该网络,清空环境 LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
class ITC090402_UpdateProfile_DupName(BaseTestCase): """ @summary: ITC-06配置集管理-04编辑配置集-01重名 """ def setUp(self): self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() # 首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"] # 创建两个配置集 self.proapi = ProfilesAPIs() LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name1) self.proapi.createProfiles(self.dm.profile_info1, self.nw_id) LogPrint().info("Pre-Test-3: Create a profile %s for this network." % self.dm.profile_name2) self.proapi.createProfiles(self.dm.profile_info2, self.nw_id) def test_UpdateProfile(self): """ @summary: 编辑配置集,重名 @note: 操作失败,验证返回状态码,验证报错信息 """ # 编辑配置集1,使其名字和配置集2重名 self.flag = True LogPrint().info("Test: Update profile %s.Set its name be %s." % (self.dm.profile_name1, self.dm.profile_name2)) r = self.proapi.updateProfile(self.dm.profile_name1, self.nw_id, self.dm.update_info) if r["status_code"] == self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict(r["result"], xmltodict.parse(self.dm.expected_info)): LogPrint().info("PASS: The returned status code and messages are CORRECT when update dup profile.") else: LogPrint().error("FAIL: The returned messages are INCORRECCT when update dup profile.") self.flag = False else: LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r["status_code"]) self.flag = False self.assertTrue(self.flag) def tearDown(self): # 删除该网络,清空环境 LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
class ITC090402_UpdateProfile_DupName(BaseTestCase): ''' @summary: ITC-06配置集管理-04编辑配置集-01重名 ''' def setUp(self): self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC."%self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] #创建两个配置集 self.proapi = ProfilesAPIs() LogPrint().info("Pre-Test-2: Create a profile %s for this network."%self.dm.profile_name1) self.proapi.createProfiles(self.dm.profile_info1, self.nw_id) LogPrint().info("Pre-Test-3: Create a profile %s for this network."%self.dm.profile_name2) self.proapi.createProfiles(self.dm.profile_info2, self.nw_id) def test_UpdateProfile(self): ''' @summary: 编辑配置集,重名 @note: 操作失败,验证返回状态码,验证报错信息 ''' #编辑配置集1,使其名字和配置集2重名 self.flag = True LogPrint().info("Test: Update profile %s.Set its name be %s."%(self.dm.profile_name1, self.dm.profile_name2)) r = self.proapi.updateProfile(self.dm.profile_name1, self.nw_id, self.dm.update_info) if r['status_code'] == self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict(r['result'], xmltodict.parse(self.dm.expected_info)): LogPrint().info("PASS: The returned status code and messages are CORRECT when update dup profile.") else: LogPrint().error("FAIL: The returned messages are INCORRECCT when update dup profile.") self.flag = False else: LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r['status_code']) self.flag = False self.assertTrue(self.flag) def tearDown(self): #删除该网络,清空环境 LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
def test_CreateProfile_VerifyName(self): ''' @summary: 验证名称合法性:包含非法字符 @note: 操作失败,验证返回状态码和报错信息 ''' self.proapi = ProfilesAPIs() self.flag = True LogPrint().info("Test: Create a profile for network %s."%self.dm.nw_name) r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id) if r['status_code']==self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info), r['result']): LogPrint().info("PASS: The returned status code and messages are CORRECT.") else: LogPrint().error("FAIL: The returned messages are INCORRECT.") self.flag = False else: LogPrint().error("FAIL: The returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code)) self.flag = False self.assertTrue(self.flag)
class ITC090303_CreateProfile_DupName(BaseTestCase): """ @summary: ITC-06配置集管理-03新建一个配置集-03名称重复 """ def setUp(self): """ @summary: 测试用例执行前的环境初始化(前提) """ self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() # 首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"] # 创建一个配置集 LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name) self.proapi = ProfilesAPIs() self.proapi.createProfiles(self.dm.profile_info, self.nw_id) def test_CreateProfile_DupName(self): """ @note: 操作失败,检查返回状态码和提示信息 """ self.flag = True LogPrint().info("Test: Create a dupname profile for network %s." % self.dm.nw_name) r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id) if r["status_code"] == self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict(r["result"], xmltodict.parse(self.dm.expected_info)): LogPrint().info("PASS: The returned status code and messages are CORRECT when create dup profile.") else: LogPrint().error("FAIL: The returned messages are INCORRECCT when create dup profile.") self.flag = False else: LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r["status_code"]) self.flag = False self.assertTrue(self.flag) def tearDown(self): LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
class ITC090401_UpdateProfile(BaseTestCase): ''' @summary: ITC-06配置集管理-04编辑配置集-01成功编辑 ''' def setUp(self): self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC."%self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] self.proapi = ProfilesAPIs() LogPrint().info("Pre-Test-2: Create a profile %s for this network."%self.dm.profile_name) self.proapi.createProfiles(self.dm.profile_info, self.nw_id) def test_UpdateProfile(self): ''' @summary: 编辑配置集 @note: 操作成功,验证返回状态码,验证接口返回信息 ''' self.flag = True LogPrint().info("Test: Update profile %s of network %s."%(self.dm.profile_name, self.dm.nw_name)) r = self.proapi.updateProfile(self.dm.profile_name, self.nw_id, self.dm.update_info) if r['status_code'] == self.dm.expected_status_code: dict_actual = r['result'] dict_expected = xmltodict.parse(self.dm.update_info) dictCompare = DictCompare() if dictCompare.isSubsetDict(dict_expected, dict_actual): LogPrint().info("PASS: Update Profile info SUCCESS." ) else: LogPrint().error("FAIL: Update Profile info INCORRECT.") self.flag = False else: LogPrint().error("FAIL: The returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag) def tearDown(self): #删除该网络,清空环境 LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
class ITC090303_CreateProfile_DupName(BaseTestCase): ''' @summary: ITC-06配置集管理-03新建一个配置集-03名称重复 ''' def setUp(self): ''' @summary: 测试用例执行前的环境初始化(前提) ''' self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC."%self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] #创建一个配置集 LogPrint().info("Pre-Test-2: Create a profile %s for this network."%self.dm.profile_name) self.proapi = ProfilesAPIs() self.proapi.createProfiles(self.dm.profile_info, self.nw_id) def test_CreateProfile_DupName(self): ''' @note: 操作失败,检查返回状态码和提示信息 ''' self.flag = True LogPrint().info("Test: Create a dupname profile for network %s."% self.dm.nw_name) r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id) if r['status_code'] == self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict(r['result'], xmltodict.parse(self.dm.expected_info)): LogPrint().info("PASS: The returned status code and messages are CORRECT when create dup profile.") else: LogPrint().error("FAIL: The returned messages are INCORRECCT when create dup profile.") self.flag = False else: LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r['status_code']) self.flag = False self.assertTrue(self.flag) def tearDown(self): LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
class ITC0905_DeleteProfile(BaseTestCase): """ @summary: ITC-06配置集管理-05删除配置集 """ def setUp(self): self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() # 首先网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"] # 为网络创建一个配置集 LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name) self.proapi = ProfilesAPIs() self.proapi.createProfiles(self.dm.profile_info, self.nw_id) def test_DeleteProfile(self): """ @summary: 删除配置集 @note: 操作成功,验证返回状态码,验证配置集是否存在 """ self.flag = True LogPrint().info("Test: Delete profile %s." % self.dm.profile_name) r = self.proapi.delProfile(self.dm.profile_name, self.nw_id) if r["status_code"] == self.dm.expected_status_code: if not self.proapi.isExist(self.dm.profile_name, self.nw_id): LogPrint().info("PASS: Delete profile %s SUCCESS." % self.dm.profile_name) else: LogPrint().error("FAIL: Profile %s is still exist." % self.dm.profile_name) self.flag = False else: LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r["status_code"]) self.flag = False self.assertTrue(self.flag) def tearDown(self): # 删除该网络,清空环境 LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
class ITC090304_CreateProfile_NoRequired(BaseTestCase): """ @summary: ITC-06配置集管理-03创建一个配置集-04验证参数完整性 """ def setUp(self): """ @summary: 测试用例执行前的环境初始化(前提) """ self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() # 首先新建一个网络并获取其id LogPrint().info("Pre-Test: Create a network %s for TC." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"] def test_CreateProfile_NoRequired(self): """ @summary: 分为三种情况,1)缺少名称 2)缺少网络id 3)提供网络名称而非网络id @note: 操作失败,验证返回状态码和报错信息 """ self.expected_result_index = 0 self.proapi = ProfilesAPIs() @BaseTestCase.drive_data(self, self.dm.profile_info) def do_test(xml_info): self.flag = True LogPrint().info("Test: Create a profile for network %s." % self.dm.nw_name) r = self.proapi.createProfiles(xml_info) if r["status_code"] == self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict( xmltodict.parse(self.dm.expected_info_list[self.expected_result_index]), r["result"] ): LogPrint().info("PASS: The returned status code and messages are CORRECT.") else: LogPrint().error("FAIL: The returned messages are INCORRECT.") self.flag = False else: LogPrint().error( "FAIL: The returned status code is '%s' while it should be '%s'." % (r["status_code"], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag) self.expected_result_index += 1 do_test() def tearDown(self): LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
class ITC0905_DeleteProfile(BaseTestCase): ''' @summary: ITC-06配置集管理-05删除配置集 ''' def setUp(self): self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC."%self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] #为网络创建一个配置集 LogPrint().info("Pre-Test-2: Create a profile %s for this network."%self.dm.profile_name) self.proapi = ProfilesAPIs() self.proapi.createProfiles(self.dm.profile_info, self.nw_id) def test_DeleteProfile(self): ''' @summary: 删除配置集 @note: 操作成功,验证返回状态码,验证配置集是否存在 ''' self.flag = True LogPrint().info("Test: Delete profile %s."%self.dm.profile_name) r = self.proapi.delProfile(self.dm.profile_name, self.nw_id) if r['status_code'] == self.dm.expected_status_code: if not self.proapi.isExist(self.dm.profile_name, self.nw_id): LogPrint().info("PASS: Delete profile %s SUCCESS."%self.dm.profile_name) else: LogPrint().error("FAIL: Profile %s is still exist."%self.dm.profile_name) self.flag = False else: LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r['status_code']) self.flag = False self.assertTrue(self.flag) def tearDown(self): #删除该网络,清空环境 LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
def test_CreateProfile(self): ''' @summary: 创建配置集 @note: 操作成功,验证返回状态码,验证接口返回信息 ''' self.flag = True self.proapi = ProfilesAPIs() LogPrint().info("Test: Create a profile %s for network %s."%(self.dm.profile_name, self.dm.nw_name)) r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id) if r['status_code'] == self.dm.expected_status_code: dict_actual = r['result'] dict_expected = xmltodict.parse((self.dm.profile_info %self.nw_id)) dictCompare = DictCompare() if dictCompare.isSubsetDict(dict_expected, dict_actual): LogPrint().info("PASS: Create profile %s for network %s SUCCESS."%(self.dm.profile_name, self.dm.nw_name)) # return True else: LogPrint().error("FAIL:Returned Profile info INCORRECT.") self.flag = False else: LogPrint().error("FAIL: Returned status code is %s not %s. "% (r['status_code'], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag)
def test_GetProfileList(self): """ @summary: 获取系统配置集列表 @note: 操作成功,验证返回状态码 """ self.proapi = ProfilesAPIs() LogPrint().info("Test: Get profile list.") r = self.proapi.getProfilesList() if r["status_code"] == 200: LogPrint().info("PASS: Get profile list SUCCESS.") self.flag = True else: LogPrint().error("FAIL: Returned status code is WRONG.") self.flag = False self.assertTrue(self.flag)
class ITC090301_CreateProfile(BaseTestCase): """ @summary: ITC-06配置集管理-03创建配置集-01成功创建 """ def setUp(self): """ @summary: 测试用例执行前的环境初始化(前提) """ self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() # 首先新建一个网络并获取其id LogPrint().info("Pre-Test: Create a network %s for TC." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"] def test_CreateProfile(self): """ @summary: 创建配置集 @note: 操作成功,验证返回状态码,验证接口返回信息 """ self.flag = True self.proapi = ProfilesAPIs() LogPrint().info("Test: Create a profile %s for network %s." % (self.dm.profile_name, self.dm.nw_name)) r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id) if r["status_code"] == self.dm.expected_status_code: dict_actual = r["result"] dict_expected = xmltodict.parse((self.dm.profile_info % self.nw_id)) dictCompare = DictCompare() if dictCompare.isSubsetDict(dict_expected, dict_actual): LogPrint().info( "PASS: Create profile %s for network %s SUCCESS." % (self.dm.profile_name, self.dm.nw_name) ) # return True else: LogPrint().error("FAIL:Returned Profile info INCORRECT.") self.flag = False else: LogPrint().error( "FAIL: Returned status code is %s not %s. " % (r["status_code"], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag) def tearDown(self): LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
def setUp(self): self.dm = super(self.__class__, self).setUp() LogPrint().info("Pre-Test-1: Create a template %s for TC." % self.dm.temp_name) self.assertTrue( smart_create_template(self.dm.temp_name, self.dm.temp_info)) #为所在数据中心的ovirtmgmt网络创建一个配置集 LogPrint().info("Pre-Test-2: Create a profile %s for ovirtmgmt." % self.dm.profile_name) self.nw_id = NetworkAPIs().getNetworkIdByName('ovirtmgmt', self.dm.dc_name) print self.nw_id r = ProfilesAPIs().createProfiles(self.dm.profile_info, self.nw_id) if r['status_code'] == 201: self.proid = r['result']['vnic_profile']['@id'] LogPrint().info("Create Profile SUCCESS.") else: LogPrint().error("Create Profile fail.The status_code is WRONG.")
class ITC090304_CreateProfile_NoRequired(BaseTestCase): ''' @summary: ITC-06配置集管理-03创建一个配置集-04验证参数完整性 ''' def setUp(self): ''' @summary: 测试用例执行前的环境初始化(前提) ''' self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先新建一个网络并获取其id LogPrint().info("Pre-Test: Create a network %s for TC."%self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] def test_CreateProfile_NoRequired(self): ''' @summary: 分为三种情况,1)缺少名称 2)缺少网络id 3)提供网络名称而非网络id @note: 操作失败,验证返回状态码和报错信息 ''' self.expected_result_index = 0 self.proapi = ProfilesAPIs() @BaseTestCase.drive_data(self, self.dm.profile_info) def do_test(xml_info): self.flag = True LogPrint().info("Test: Create a profile for network %s."%self.dm.nw_name) r = self.proapi.createProfiles(xml_info) if r['status_code']==self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info_list[self.expected_result_index]), r['result']): LogPrint().info("PASS: The returned status code and messages are CORRECT.") else: LogPrint().error("FAIL: The returned messages are INCORRECT.") self.flag = False else: LogPrint().error("FAIL: The returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code)) self.flag = False self.assertTrue(self.flag) self.expected_result_index += 1 do_test() def tearDown(self): LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
class ITC090302_CreateProfile_VerifyName(BaseTestCase): """ @summary: ITC-06配置集管理-03创建配置集-02验证名称合法性 """ def setUp(self): """ @summary: 测试用例执行前的环境初始化(前提) """ self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() # 首先新建一个网络并获取其id LogPrint().info("Pre-Test: Create a network %s for TC." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"] def test_CreateProfile_VerifyName(self): """ @summary: 验证名称合法性:包含非法字符 @note: 操作失败,验证返回状态码和报错信息 """ self.proapi = ProfilesAPIs() self.flag = True LogPrint().info("Test: Create a profile for network %s." % self.dm.nw_name) r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id) if r["status_code"] == self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info), r["result"]): LogPrint().info("PASS: The returned status code and messages are CORRECT.") else: LogPrint().error("FAIL: The returned messages are INCORRECT.") self.flag = False else: LogPrint().error( "FAIL: The returned status code is '%s' while it should be '%s'." % (r["status_code"], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag) def tearDown(self): LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
class ITC090301_CreateProfile(BaseTestCase): ''' @summary: ITC-06配置集管理-03创建配置集-01成功创建 ''' def setUp(self): ''' @summary: 测试用例执行前的环境初始化(前提) ''' self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先新建一个网络并获取其id LogPrint().info("Pre-Test: Create a network %s for TC."%self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] def test_CreateProfile(self): ''' @summary: 创建配置集 @note: 操作成功,验证返回状态码,验证接口返回信息 ''' self.flag = True self.proapi = ProfilesAPIs() LogPrint().info("Test: Create a profile %s for network %s."%(self.dm.profile_name, self.dm.nw_name)) r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id) if r['status_code'] == self.dm.expected_status_code: dict_actual = r['result'] dict_expected = xmltodict.parse((self.dm.profile_info %self.nw_id)) dictCompare = DictCompare() if dictCompare.isSubsetDict(dict_expected, dict_actual): LogPrint().info("PASS: Create profile %s for network %s SUCCESS."%(self.dm.profile_name, self.dm.nw_name)) # return True else: LogPrint().error("FAIL:Returned Profile info INCORRECT.") self.flag = False else: LogPrint().error("FAIL: Returned status code is %s not %s. "% (r['status_code'], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag) def tearDown(self): LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
class ITC090302_CreateProfile_VerifyName(BaseTestCase): ''' @summary: ITC-06配置集管理-03创建配置集-02验证名称合法性 ''' def setUp(self): ''' @summary: 测试用例执行前的环境初始化(前提) ''' self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先新建一个网络并获取其id LogPrint().info("Pre-Test: Create a network %s for TC."%self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] def test_CreateProfile_VerifyName(self): ''' @summary: 验证名称合法性:包含非法字符 @note: 操作失败,验证返回状态码和报错信息 ''' self.proapi = ProfilesAPIs() self.flag = True LogPrint().info("Test: Create a profile for network %s."%self.dm.nw_name) r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id) if r['status_code']==self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info), r['result']): LogPrint().info("PASS: The returned status code and messages are CORRECT.") else: LogPrint().error("FAIL: The returned messages are INCORRECT.") self.flag = False else: LogPrint().error("FAIL: The returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code)) self.flag = False self.assertTrue(self.flag) def tearDown(self): LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
def test_CreateProfile_VerifyName(self): """ @summary: 验证名称合法性:包含非法字符 @note: 操作失败,验证返回状态码和报错信息 """ self.proapi = ProfilesAPIs() self.flag = True LogPrint().info("Test: Create a profile for network %s." % self.dm.nw_name) r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id) if r["status_code"] == self.dm.expected_status_code: dictCompare = DictCompare() if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info), r["result"]): LogPrint().info("PASS: The returned status code and messages are CORRECT.") else: LogPrint().error("FAIL: The returned messages are INCORRECT.") self.flag = False else: LogPrint().error( "FAIL: The returned status code is '%s' while it should be '%s'." % (r["status_code"], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag)
#encoding:utf-8 from TestAPIs.StorageDomainAPIs import StorageDomainAPIs from TestAPIs.ProfilesAPIs import ProfilesAPIs from TestAPIs.NetworkAPIs import NetworkAPIs import TestData.VirtualMachine.ITC05_SetUp as ModuleData ''' @note: PreData ''' ''' @note: 这里使用数据中心自带的ovirtmgmt/ovirtmgmt配置集 ''' nic_name = 'nic-ITC05' sd_id = StorageDomainAPIs().getStorageDomainIdByName(ModuleData.data1_nfs_name) nw_id = NetworkAPIs().getNetworkIdByName('ovirtmgmt', ModuleData.dc_nfs_name) pro_id = ProfilesAPIs().getProfileIdByName('ovirtmgmt', nw_id) nic_info = ''' <nic> <name>%s</name> <interface>virtio</interface> <linked>false</linked> <plugged>false</plugged> </nic> ''' % (nic_name) ''' @note: ExpectedData ''' expected_status_code = 200
def tearDown(self): LogPrint().info("Post-Test-1: Delete template %s." % self.dm.temp_name) self.assertTrue(smart_delete_template(self.dm.temp_name)) LogPrint().info("Post-Test-2: Delete profile %s." % self.dm.profile_name) ProfilesAPIs().delProfile(self.dm.profile_name, self.nw_id)
class ITC0902_GetProfileInfo(BaseTestCase): """ @summary: ITC-06配置集管理-02获取指定配置集信息 """ def setUp(self): """ @summary: 测试用例执行前的环境初始化(前提) """ self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() # 首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"] self.proapi = ProfilesAPIs() LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name) self.proapi.createProfiles(self.dm.profile_info, self.nw_id) def test_GetProfileInfo_byname(self): """ @summary: 根据配置集名称获取其信息 @note: 操作成功,验证返回状态码,验证接口返回信息 """ self.flag = True r = self.proapi.getProfileInfo(profile_name=self.dm.profile_name, nw_id=self.nw_id) LogPrint().info("Test-1: Get profile %s by NAME." % self.dm.profile_name) if r["status_code"] == self.dm.expected_status_code: dict_actual = r["result"] dict_expected = xmltodict.parse((self.dm.profile_info % self.nw_id)) dictCompare = DictCompare() if dictCompare.isSubsetDict(dict_expected, dict_actual): LogPrint().info("PASS: Get Profile info SUCCESS.") else: LogPrint().error("FAIL:Returned Profile info INCORRECT.") self.flag = False else: LogPrint().error( "FAIL: Returned status code is %s not %s. " % (r["status_code"], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag) def test_GetProfileInfo_id(self): """ @summary: 根据配置集id获取信息 @note: 操作成功,验证返回状态码,验证接口返回信息 """ # 测试1:根据网络id获取网络信息 self.flag = True LogPrint().info("Test-2: Get profile %s by ID." % self.dm.profile_name) profile_id = self.proapi.getProfileIdByName(self.dm.profile_name, self.nw_id) r = self.proapi.getProfileInfo(profile_id=profile_id) if r["status_code"] == self.dm.expected_status_code: dict_actual = r["result"] dict_expected = xmltodict.parse((self.dm.profile_info % self.nw_id)) dictCompare = DictCompare() if dictCompare.isSubsetDict(dict_expected, dict_actual): LogPrint().info("PASS: Get Profile info SUCCESS.") else: LogPrint().error("FAIL:Returned Profile info INCORRECT.") self.flag = False else: LogPrint().error( "FAIL: Returned status code is %s not %s. " % (r["status_code"], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag) def tearDown(self): """ @summary: 测试结束后的资源清理(恢复初始环境) """ LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
class ITC0902_GetProfileInfo(BaseTestCase): ''' @summary: ITC-06配置集管理-02获取指定配置集信息 ''' def setUp(self): ''' @summary: 测试用例执行前的环境初始化(前提) ''' self.dm = super(self.__class__, self).setUp() self.nwapi = NetworkAPIs() #首先新建一个网络并获取其id LogPrint().info("Pre-Test-1: Create a network %s for TC."%self.dm.nw_name) self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id'] self.proapi = ProfilesAPIs() LogPrint().info("Pre-Test-2: Create a profile %s for this network."%self.dm.profile_name) self.proapi.createProfiles(self.dm.profile_info,self.nw_id) def test_GetProfileInfo_byname(self): ''' @summary: 根据配置集名称获取其信息 @note: 操作成功,验证返回状态码,验证接口返回信息 ''' self.flag = True r = self.proapi.getProfileInfo(profile_name=self.dm.profile_name, nw_id=self.nw_id) LogPrint().info("Test-1: Get profile %s by NAME."%self.dm.profile_name) if r['status_code'] == self.dm.expected_status_code: dict_actual = r['result'] dict_expected = xmltodict.parse((self.dm.profile_info %self.nw_id)) dictCompare = DictCompare() if dictCompare.isSubsetDict(dict_expected, dict_actual): LogPrint().info("PASS: Get Profile info SUCCESS." ) else: LogPrint().error("FAIL:Returned Profile info INCORRECT.") self.flag = False else: LogPrint().error("FAIL: Returned status code is %s not %s. "% (r['status_code'], self.dm.expected_status_code) ) self.flag = False self.assertTrue(self.flag) def test_GetProfileInfo_id(self): ''' @summary: 根据配置集id获取信息 @note: 操作成功,验证返回状态码,验证接口返回信息 ''' # 测试1:根据网络id获取网络信息 self.flag = True LogPrint().info("Test-2: Get profile %s by ID."%self.dm.profile_name) profile_id = self.proapi.getProfileIdByName(self.dm.profile_name, self.nw_id) r = self.proapi.getProfileInfo(profile_id=profile_id) if r['status_code'] == self.dm.expected_status_code: dict_actual = r['result'] dict_expected = xmltodict.parse((self.dm.profile_info %self.nw_id)) dictCompare = DictCompare() if dictCompare.isSubsetDict(dict_expected, dict_actual): LogPrint().info("PASS: Get Profile info SUCCESS.") else: LogPrint().error("FAIL:Returned Profile info INCORRECT.") self.flag = False else: LogPrint().error("FAIL: Returned status code is %s not %s. "% (r['status_code'], self.dm.expected_status_code)) self.flag = False self.assertTrue(self.flag) def tearDown(self): ''' @summary: 测试结束后的资源清理(恢复初始环境) ''' LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name) self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)