def __validate_contain_group(self, oper_resp, orig_DOM, exp_contain=True):
        xml_resp_stream = (oper_resp.text).encode('utf-8', 'ignore')
        xml_resp_DOM = md.parseString(xml_resp_stream)
        nodeListOperGroup = xml_resp_DOM.getElementsByTagName('group-desc')
        if (nodeListOperGroup.length > 1):
            err_msg = '\n !!! Operational Data Store has more groups as one \n'
            self.log.error(self._paint_msg_red(err_msg))
            raise AssertionError(err_msg)

        origDict = XMLtoDictParserTools.parseDOM_ToDict(
            orig_DOM._get_documentElement(),
            ignoreList=IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON)
        origDict['group-desc'] = origDict.pop('group')
        nodeDict = {}
        for node in nodeListOperGroup:
            nodeDict = XMLtoDictParserTools.parseDOM_ToDict(
                node, ignoreList=IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON)
        if exp_contain:
            if nodeDict != origDict:
                err_msg = '\n !!! Loaded operation statistics doesn\'t contain expected group \n' \
                            ' expected:      %s\n found:         %s\n differences:   %s\n' \
                            '' % ( origDict, nodeDict, XMLtoDictParserTools.getDifferenceDict( origDict, nodeDict ) )
                self.log.error(self._paint_msg_red(err_msg))
                raise AssertionError(err_msg)

        else:
            if nodeDict == origDict:
                err_msg = '\n !!! Loaded operation statistics contains expected group, delete fail \n' \
                            ' found:         %s\n' % ( nodeDict )
                self.log.error(self._paint_msg_red(err_msg))
                raise AssertionError(err_msg)
    def __validate_contain_group( self, oper_resp, orig_DOM, exp_contain = True ):
        xml_resp_stream = ( oper_resp.text ).encode( 'utf-8', 'ignore' )
        xml_resp_DOM = md.parseString( xml_resp_stream )
        nodeListOperGroup = xml_resp_DOM.getElementsByTagName( 'group-desc' )
        if ( nodeListOperGroup.length > 1 ) :
            err_msg = '\n !!! Operational Data Store has more groups as one \n'
            self.log.error( self._paint_msg_red( err_msg ) )
            raise AssertionError( err_msg )

        origDict = XMLtoDictParserTools.parseDOM_ToDict( orig_DOM._get_documentElement(),
                                                        ignoreList = IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON )
        origDict['group-desc'] = origDict.pop( 'group' )
        nodeDict = {}
        for node in nodeListOperGroup :
            nodeDict = XMLtoDictParserTools.parseDOM_ToDict( node,
                                                            ignoreList = IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON )
        if exp_contain :
            if nodeDict != origDict :
                err_msg = '\n !!! Loaded operation statistics doesn\'t contain expected group \n' \
                            ' expected:      %s\n found:         %s\n differences:   %s\n' \
                            '' % ( origDict, nodeDict, XMLtoDictParserTools.getDifferenceDict( origDict, nodeDict ) )
                self.log.error( self._paint_msg_red( err_msg ) )
                raise AssertionError( err_msg )

        else :
            if nodeDict == origDict :
                err_msg = '\n !!! Loaded operation statistics contains expected group, delete fail \n' \
                            ' found:         %s\n' % ( nodeDict )
                self.log.error( self._paint_msg_red( err_msg ) )
                raise AssertionError( err_msg )
 def __validate_contain_flow( self, oper_resp, orig_DOM, exp_contain = True ):
     xml_resp_stream = ( oper_resp.text ).encode( 'utf-8', 'ignore' )
     xml_resp_DOM = md.parseString( xml_resp_stream )
     nodeListOperFlows = xml_resp_DOM.getElementsByTagName( 'flow-statistics' )
     origDict = XMLtoDictParserTools.parseDOM_ToDict( orig_DOM._get_documentElement(),
                                                     ignoreList = IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON )
     origDict['flow-statistics'] = origDict.pop( 'flow' )
     nodeDict = {}
     for node in nodeListOperFlows :
         if self.__is_wanted_flow( orig_DOM, node ) :
             nodeDict = XMLtoDictParserTools.parseDOM_ToDict( node,
                                                             ignoreList = IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON )
             break
     if exp_contain :
         if nodeDict != origDict :
             err_msg = '\n!!!!! Loaded operation statistics doesn\'t contain expected flow \n' \
                         ' expected:      %s\n found:         %s\n differences:   %s\n' \
                         '' % ( origDict, nodeDict, XMLtoDictParserTools.getDifferenceDict( origDict, nodeDict ) )
             self.log.error( self._paint_msg_red( err_msg ) )
             raise AssertionError( err_msg )
     else :
         if nodeDict == origDict :
             err_msg = '\n !!! Loaded operation statistics contains expected flow, delete fail \n' \
                         ' found:         %s\n' % ( nodeDict )
             self.log.error( self._paint_msg_red( err_msg ) )
             raise AssertionError( err_msg )
Exemple #4
0
 def __validate_contain_flow(self, oper_resp, orig_DOM, exp_contain=True):
     xml_resp_stream = (oper_resp.text).encode('utf-8', 'ignore')
     xml_resp_DOM = md.parseString(xml_resp_stream)
     nodeListOperFlows = xml_resp_DOM.getElementsByTagName(
         'flow-statistics')
     origDict = XMLtoDictParserTools.parseDOM_ToDict(
         orig_DOM._get_documentElement(),
         ignoreList=IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON)
     origDict['flow-statistics'] = origDict.pop('flow')
     nodeDict = {}
     for node in nodeListOperFlows:
         if self.__is_wanted_flow(orig_DOM, node):
             nodeDict = XMLtoDictParserTools.parseDOM_ToDict(
                 node, ignoreList=IGNORED_TAGS_FOR_OPERATIONAL_COMPARISON)
             break
     if exp_contain:
         if nodeDict != origDict:
             err_msg = '\n!!!!! Loaded operation statistics doesn\'t contain expected flow \n' \
                         ' expected:      %s\n found:         %s\n differences:   %s\n' \
                         '' % ( origDict, nodeDict, XMLtoDictParserTools.getDifferenceDict( origDict, nodeDict ) )
             self.log.error(self._paint_msg_red(err_msg))
             raise AssertionError(err_msg)
     else:
         if nodeDict == origDict:
             err_msg = '\n !!! Loaded operation statistics contains expected flow, delete fail \n' \
                         ' found:         %s\n' % ( nodeDict )
             self.log.error(self._paint_msg_red(err_msg))
             raise AssertionError(err_msg)
 def assertDataDOM( self, orig_DOM_Doc, resp_DOM_Doc ):
     """
     assertDataDOM - help method for assertion the two DOM data representation
                       e.g. the request xml and the config Data Store result
                       has to be same always
     @param orig_DOM_Doc: DOM Document sends to controller (e.g. from file input)
     @param resp_DOM_Doc: DOM Document returns from response 
     @raise AssertionError: if response has not the expected 404 code
     """
     origDict = XMLtoDictParserTools.parseDOM_ToDict( orig_DOM_Doc._get_documentElement() )
     respDict = XMLtoDictParserTools.parseDOM_ToDict( resp_DOM_Doc._get_documentElement() )
     if ( respDict != origDict ) :
         err_msg = '\n !!! Uploaded and stored xml, are not the same\n' \
             ' uploaded:      %s\n stored:        %s\n differences:   %s\n' \
             '' % ( origDict, respDict, XMLtoDictParserTools.getDifferenceDict( origDict, respDict ) )
         self.log.error( self._paint_msg_red( err_msg ) )
         raise AssertionError( err_msg )