def testGetParametersDict(self): task1 = Task(TaskInfo("",TestTask.workingDirectory, TestTask.targetFolder1)) paramDict = task1.getTaskInfo().getParametersDict() self.assertEquals(0, len(paramDict))
def testGetParametersDict(self): task1 = Task( TaskInfo("", TestTask.workingDirectory, TestTask.targetFolder1)) paramDict = task1.getTaskInfo().getParametersDict() self.assertEqual(0, len(paramDict))
def testExecute(self): task1 = Task(TaskInfo("",TestTask.workingDirectory, TestTask.targetFolder1)) task1.validateParameters = lambda : Task.validateParameters(task1,[]) task1.execute()
def testSetResults(self): task1 = Task( TaskInfo("", TestTask.workingDirectory, TestTask.targetFolder1)) task1.setResult("error", "message") self.assertEqual("error", task1.resultErrorFlag) self.assertEqual("message", task1.resultMessage)
def testSetResults(self): task1 = Task(TaskInfo("",TestTask.workingDirectory, TestTask.targetFolder1)) task1.setResult("error", "message") self.assertEqual("error", task1.resultErrorFlag) self.assertEqual("message", task1.resultMessage)
def __init__(self, taskInfo): """Default constructor. """ Task.__init__(self, taskInfo) self.count = 0 self.debug = False self.textFiltering = False self.removePunctuation = False self.verbalizePunctuation = False self.lmModeling = False
def testValidateParameters(self): task1 = Task(TaskInfo("",TestTask.workingDirectory, TestTask.targetFolder1)) with self.assertRaises(Exception): task1.validateParameters(["param1"]) Task.COMMON_PARAMETERS = ["param1"] with self.assertRaises(Exception): task1.validateParameters([]) Task.COMMON_PARAMETERS = []
def validateParameters(self): """Check that language and batch file parameters are specified. """ self._log(logging.INFO, "Validate parameters") return Task.validateParameters(self, ImportDocumentTask.PARAMETERS)
def testExecute(self): task1 = Task( TaskInfo("", TestTask.workingDirectory, TestTask.targetFolder1)) task1.validateParameters = lambda: Task.validateParameters(task1, []) task1.execute()
def testBuildParametersDict(self): task1 = Task(TaskInfo("param1=v1;param2=v2", TestTask.workingDirectory, TestTask.targetFolder1)) task1._buildParametersDictionary() task1 = Task(TaskInfo("param1=;param2=v2", TestTask.workingDirectory, TestTask.targetFolder1)) with self.assertRaises(Exception): task1._buildParametersDictionary() task1 = Task(TaskInfo("=v1;param2=v2", TestTask.workingDirectory, TestTask.targetFolder1)) with self.assertRaises(Exception): task1._buildParametersDictionary()
def testValidateParameters(self): task1 = Task( TaskInfo("", TestTask.workingDirectory, TestTask.targetFolder1)) with self.assertRaises(Exception): task1.validateParameters(["param1"]) Task.COMMON_PARAMETERS = ["param1"] with self.assertRaises(Exception): task1.validateParameters([]) Task.COMMON_PARAMETERS = []
def testBuildTaskPath(self): task1 = Task( TaskInfo("", TestTask.workingDirectory, TestTask.targetFolder1)) with self.assertRaises(Exception): task1._buildTaskPath("path")
def testBuildTask(self): task1 = Task( TaskInfo("", TestTask.workingDirectory, TestTask.targetFolder1)) self.assertTrue(task1.taskUniqueId > 0)
def testBuildParametersDict(self): task1 = Task( TaskInfo("param1=v1;param2=v2", TestTask.workingDirectory, TestTask.targetFolder1)) task1._buildParametersDictionary() task1 = Task( TaskInfo("param1=;param2=v2", TestTask.workingDirectory, TestTask.targetFolder1)) with self.assertRaises(Exception): task1._buildParametersDictionary() task1 = Task( TaskInfo("=v1;param2=v2", TestTask.workingDirectory, TestTask.targetFolder1)) with self.assertRaises(Exception): task1._buildParametersDictionary()
def testGatherInputData(self): #No data olist task1 = Task( TaskInfo("", TestTask.workingDirectory, TestTask.targetFolderErr1)) with self.assertRaises(Exception): task1.gatherInputData() #No map .omap task1 = Task( TaskInfo("", TestTask.workingDirectory, TestTask.targetFolderErr2)) with self.assertRaises(Exception): task1.gatherInputData() task1 = Task( TaskInfo("", TestTask.workingDirectory, TestTask.targetFolder1)) task1.gatherInputData() self.assertTrue(MyFile.checkFileExists(task1.getTaskDirectory())) self.assertTrue(MyFile.checkFileExists(task1.getInputDirectory())) self.assertTrue(MyFile.checkFileExists(task1.getTempDirectory())) self.assertTrue(MyFile.checkFileExists(task1.getOutputDirectory())) dataListPath = "%s%s%s" % (task1.getInputDirectory(), os.sep, 'data.ilist') dataMap1Path = "%s%s%s" % (task1.getInputDirectory(), os.sep, 'audio.imap') dataMap2Path = "%s%s%s" % (task1.getInputDirectory(), os.sep, 'model.imap') self.assertTrue(MyFile.checkFileExists(dataListPath)) self.assertTrue(MyFile.checkFileExists(dataMap1Path)) self.assertTrue(MyFile.checkFileExists(dataMap2Path)) self.assertEqual(15, task1.inputList.getCount()) self.assertEqual(2, len(task1.mapLists)) for dataMap in task1.mapLists: self.assertTrue(dataMap.getCount() in [2, 1]) task1 = Task( TaskInfo("", TestTask.workingDirectory, TestTask.targetFolderErr)) #Two input lists with self.assertRaises(Exception): task1.gatherInputData()
def testBuildTaskPath(self): task1 = Task(TaskInfo("",TestTask.workingDirectory, TestTask.targetFolder1)) with self.assertRaises(Exception): task1._buildTaskPath("path")
def testGatherInputData(self): #No data olist task1 = Task(TaskInfo("",TestTask.workingDirectory, TestTask.targetFolderErr1)) with self.assertRaises(Exception): task1.gatherInputData() #No map .omap task1 = Task(TaskInfo("",TestTask.workingDirectory, TestTask.targetFolderErr2)) with self.assertRaises(Exception): task1.gatherInputData() task1 = Task(TaskInfo("",TestTask.workingDirectory, TestTask.targetFolder1)) task1.gatherInputData() self.assertTrue(MyFile.checkFileExists(task1.getTaskDirectory())) self.assertTrue(MyFile.checkFileExists(task1.getInputDirectory())) self.assertTrue(MyFile.checkFileExists(task1.getTempDirectory())) self.assertTrue(MyFile.checkFileExists(task1.getOutputDirectory())) dataListPath = "%s%s%s" % (task1.getInputDirectory(),os.sep,'data.ilist') dataMap1Path = "%s%s%s" % (task1.getInputDirectory(),os.sep,'audio.imap') dataMap2Path = "%s%s%s" % (task1.getInputDirectory(),os.sep,'model.imap') self.assertTrue(MyFile.checkFileExists(dataListPath)) self.assertTrue(MyFile.checkFileExists(dataMap1Path)) self.assertTrue(MyFile.checkFileExists(dataMap2Path)) self.assertEquals(15,task1.inputList.getCount()) self.assertEquals(2,len(task1.mapLists)) for dataMap in task1.mapLists: self.assertTrue(dataMap.getCount() in [2,1]) task1 = Task(TaskInfo("",TestTask.workingDirectory, TestTask.targetFolderErr)) #Two input lists with self.assertRaises(Exception): task1.gatherInputData()