def update(self, objectClassName, requestBody, category, testCaseId): NsmUtil.printHeadLine2('START: update test case ' + str(testCaseId)) self.updateUrl = self.uid + '/put' self.logger.info('update request url: ' + self.updateUrl) if self.mySubClassName != 'Pod': self.logger.info('request body: ' + "\n\n" + requestBody +"\n") else: podRequestFilePath = Define._PathLog + '/pod-request-body.xml' Util.writeFile(podRequestFilePath, requestBody) name = self.createName + ' Update ' + category + ' ' + str(testCaseId) nameDash = name.replace(' ', '-') debugUpdateClassPath = Define._PathResponseUpdate + '/' + objectClassName Util.mkdir(debugUpdateClassPath) debugUpdateFilePath = debugUpdateClassPath + '/' + nameDash + '.xml' status = None if (self.isOffLine): self.logger.debug('get update task from file: ' + debugUpdateFilePath) self.updateTaskXml = Util.readFile(debugUpdateFilePath) myTask = Task(self.updateTaskXml) status = myTask.checkResult() self.updateTaskXml = myTask.taskXml else: self.updateTaskXml = HttpUtil.doPost(self.updateUrl, Define._credential, requestBody) if not self.updateTaskXml: return False self.logger.debug('write pending update task to file: ' + debugUpdateFilePath + '-pending.xml') Util.writeFile(debugUpdateFilePath+'-pending.xml', self.updateTaskXml) myTask = Task(self.updateTaskXml) status = myTask.checkResult() self.updateTaskXml = myTask.taskXml self.logger.info('write final update task to file ' + debugUpdateFilePath) #self.logger.info(self.updateTaskXml) Util.writeFile(debugUpdateFilePath, self.updateTaskXml) NsmUtil.printHeadLine2('END: update test case ' + str(testCaseId)) return status
def mkPresetDir(): Util.mkdir(Define._PathResponseCreateDefault) Util.mkdir(Define._PathResponseCreateSetup) Util.mkdir(Define._PathResponseUpdate) Util.mkdir(Define._PathResponseDelete) Util.mkdir(Define._PathLog)