Exemplo n.º 1
0
 def testGroupDefinition(self, type):
     for test in TestConstant.group_tasks.keys():
         print '\nGroup Defn Test Task: %s' % test
         file = self.path + test + '.csv'
         data = CSVHandler.getDatafromFile(file)
         if not hasattr(self, 'groups'):
             self.groups = self.configHandler.getData('group')
         retData = self.groups[TestConstant.group_tasks[test]]
         self.verifyData(data, retData, self.__getListKey('group'))
Exemplo n.º 2
0
    def testGeneralDefinition(self, type=False):
        if type:
            tests = [type]
        else:
            tests = TestConstant.general_tasks.keys()
        for test in tests:
            print '\nTest %s' % test
            myPath = self.__getPath(
                type) + '.' + TestConstant.general_tasks[type]
            if TestConstant.general_tasks[type] == 'xml':
                indexData = XmlHandler.getDatafromFile(myPath, type)
            elif TestConstant.general_tasks[type] == 'csv':
                indexData = CSVHandler.getDatafromFile(myPath, type=type)
            retData = self.configHandler.getData(test)

            self.verifyData(indexData, retData, testUtility.getListKey(type))
Exemplo n.º 3
0
    def __getOriData(self, task, fileName):
        test, type = fileName.split('.')
        path = self.__getPath(task)
        file = path + fileName
        if type == 'csv':
            data = CSVHandler.getDatafromFile(file)
        elif type == 'xml':
            mydata = XMLHelper.unpickleFile(file, XML_TYPE[test], type='list')
            data = {}
            for item in mydata:
                for attr in classUtility.getAttrList(item):
                    if attr in SPECIAL_LIST:
                        newValue = self.__specialFormat(item, attr)
                        setattr(item, attr, newValue)
                key = getattr(item, XML_DATAKEY[test])
                data[key] = item

        return data
Exemplo n.º 4
0
    def __indexEventParser(self, fileList, type, myPath):
        for file in fileList:
            if '.xml' not in file or file in SKIP_FILES:
                fileList.remove(file)
        data = {}
        for file in fileList:
            name = file.split('.')[0]
            myFile = open(myPath + file, 'r')
            text = ''
            for line in myFile.readlines():
                text += line.replace('\n', '')
            myFile.close()
            data[name] = text
        indexData = {}
        deviceTypes = self.__getCMDBData('deviceType')
        orderData = CSVHandler.getDatafromFile(myPath + 'parserOrder.csv')
        pattern = re.compile(REGEX)
        for key in data.keys():
            if SPLIT['head'] in data[key]:
                valueHead = SPLIT['head']
            else:
                valueHead = SPLIT['althead']
            myHead = data[key].split(valueHead, 1)
            if len(myHead) == 2:
                middle = myHead[1]
            else:
                print 'there is no such data pattern.'
            myTail = middle.split(SPLIT['tail'])
            myObj = locateClassInstance.getClassInstance(type)
            myObj.attribute['name'] = key
            myObj.parserXml = valueHead + myTail[0] + SPLIT['tail']
            myWord = myHead[0].split('</deviceType')[0]
            ret = pattern.search(myWord)
            myType = ret.group('modelName') + '-' + ret.group('vendorName')
            if myType in deviceTypes.keys():
                myObj.deviceType = deviceTypes[myType]
            myObj.priority = orderData[key].priority
            indexData[key] = myObj

        return indexData