Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
0
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)    
Beispiel #4
0
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)