def testNewDefaultTask(self): # Generate two new tasks if sys.version_info[0] < 3: addTask.addTask(('testTag1,testTag2',\ 'This is the title of the task ÆØÅ'.decode('utf-8'))) addTask.addTask(('testTag1,testTag2',\ 'This is the title of the task ÆØÅ'.decode('utf-8'))) else: addTask.addTask(('testTag1,testTag2',\ 'This is the title of the task ÆØÅ')) addTask.addTask(('testTag1,testTag2',\ 'This is the title of the task ÆØÅ')) # Find the current date year, month, day = self.getTodayStrings() # Update the expected task file with the date label expTaskTemplatePath = self.testDir + \ '/test_add_task_files/default/default.tpl.tex' expTaskPath0 = self.createExpTaskFile(expTaskTemplatePath,'default',\ year,month,day,'',0) expTaskPath1 = self.createExpTaskFile(expTaskTemplatePath,'default',\ year,month,day,'',1) # Check that the actual task file is identical to the expected actTaskPath0 = self.testDir + '/../entries/' + year + '/' + month + \ '/' + day + '/' + year + month + day + '_0.tex' actTaskPath1 = self.testDir + '/../entries/' + year + '/' + month + \ '/' + day + '/' + year + month + day + '_1.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ actTaskPath0,expTaskPath0)) self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ actTaskPath1,expTaskPath1)) # remove the generated task file os.remove(expTaskPath0) os.remove(expTaskPath1)
def testNewBuildTag(self): # Test ./newBuild.sh "testTag1,testTag2" newBuild.newBuild(('testTag1,testTag2', )) expTaskList = \ self.testDir + '/test_new_build_files/tag/taskList.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.taskList,expTaskList)) expTagDictionary = \ self.testDir + '/test_new_build_files/tag/tagDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.tagDictionary,expTagDictionary)) expAuthorDictionary = \ self.testDir + '/test_new_build_files/tag/authorDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.authorDictionary,expAuthorDictionary))
def testNewBuildMonth(self): # Test ./newBuild.sh all "2013-11,2014-02" newBuild.newBuild(('all', '2013-11,2014-02')) expTaskList = \ self.testDir + '/test_new_build_files/month/taskList.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.taskList,expTaskList)) expTagDictionary = \ self.testDir + '/test_new_build_files/month/tagDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.tagDictionary,expTagDictionary)) expAuthorDictionary = \ self.testDir + '/test_new_build_files/month/authorDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.authorDictionary,expAuthorDictionary))
def testNewBuildTaskLabels(self): # Test ./newBuild.sh all all '20131102_0,20140116_2' newBuild.newBuild(('all', 'all', '20131102_0,20140116_2')) expTaskList = self.testDir + \ '/test_new_build_files/task_labels/taskList.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.taskList,expTaskList)) expTagDictionary = self.testDir + \ '/test_new_build_files/task_labels/tagDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.tagDictionary,expTagDictionary)) expAuthorDictionary = self.testDir + \ '/test_new_build_files/task_labels/authorDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.authorDictionary,expAuthorDictionary))
def testNewBuildAllExceptOneTag(self): # Test ./newBuild.sh "all,!testTag3" newBuild.newBuild(('all,!testTag3', )) expTaskList = self.testDir + \ '/test_new_build_files/include_all_but_one_tag/taskList.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.taskList,expTaskList)) expTagDictionary = self.testDir + \ '/test_new_build_files/include_all_but_one_tag/tagDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.tagDictionary,expTagDictionary)) expAuthorDictionary = self.testDir + \ '/test_new_build_files/include_all_but_one_tag/authorDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.authorDictionary,expAuthorDictionary))
def testNewBuildIncompatibleTagDate(self): # Test ./newBuild.sh "testTag2" "2014-02-12" newBuild.newBuild(('testTag2', '2014-02-12')) expTaskList = self.testDir + \ '/test_new_build_files/incompatible_tag_date/taskList.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.taskList,expTaskList)) expTagDictionary = self.testDir + \ '/test_new_build_files/incompatible_tag_date/tagDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.tagDictionary,expTagDictionary)) expAuthorDictionary = \ self.testDir + '/test_new_build_files/incompatible_tag_date/authorDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.authorDictionary,expAuthorDictionary))
def testNewBuildAll(self): # Test ./newBuild.sh all all newBuild.newBuild(('all', 'all')) expTaskList = \ self.testDir + '/test_new_build_files/all/taskList.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.taskList,expTaskList)) expTagDictionary = \ self.testDir + '/test_new_build_files/all/tagDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.tagDictionary,expTagDictionary)) expAuthorDictionary = \ self.testDir + '/test_new_build_files/all/authorDictionary.tex' self.assertTrue( commonDiaryTestFunctions.isFileContentIdentical( self.authorDictionary, expAuthorDictionary))
def testNewBuildDefault(self): # Test ./newBuild.sh newBuild.newBuild('') expTaskList = \ self.testDir + '/test_new_build_files/default/taskList.tex' # self.assertTrue(os.stat(self.taskList)[6]==0) self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.taskList,expTaskList)) expTagDictionary = \ self.testDir + '/test_new_build_files/default/tagDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.tagDictionary,expTagDictionary)) expAuthorDictionary = \ self.testDir + '/test_new_build_files/default/authorDictionary.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.authorDictionary,expAuthorDictionary))
def testChangeAndReplaceValidTag(self): oldTag = 'testTag' anotherTag = 'anotherTestTag' oldTagTitle = 'Test title' anotherTagTitle = 'Another Test title' # Add the old tag to the tag database newTag.addTag2database(list((oldTag,oldTagTitle))) newTag.addTag2database(list((anotherTag,anotherTagTitle))) # The new tag and tag title expNewTag = 'anotherTestTag' expNewTagTitle = oldTagTitle # Change the tag and tag title changeTag.updateTag(list((oldTag,expNewTag))) # Check that the tag and tag title has been updated db = DiaryDatabaseWrapper.DiaryDatabaseWrapper() tagRows = db.selectFromTable('tags',('name','title'),\ 'WHERE name=\'' + expNewTag + '\'') self.assertTrue(len(tagRows)==1) self.assertEqual(tagRows[0][0],expNewTag) self.assertEqual(tagRows[0][1],expNewTagTitle) # Check that the entries have been updated expEntry = \ self.testDir + '/test_change_tag_files/tag_replace/20140824_0.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.entryPath,expEntry))
def testAuthorInitials(self): # Generate a new task addTask.addTask(('testTag1,testTag2','This is the title of the task',\ 'jkn')) addTask.addTask(('testTag1,testTag2','This is the title of the task',\ 'shj')) addTask.addTask(('testTag1,testTag2','This is the title of the task',\ 'jkn,shj')) addTask.addTask(('testTag1,testTag2','This is the title of the task',\ 'shj,jkn')) # Find the current date year, month, day = self.getTodayStrings() # Update the expected task file with the date label expTaskTemplatePath = self.testDir + \ '/test_add_task_files/author/default.tpl.tex' expTaskPathJkn0 = self.createExpTaskFile(expTaskTemplatePath,'author',\ year,month,day,('jkn',),0) expTaskPathJkn1 = self.createExpTaskFile(expTaskTemplatePath,'author',\ year,month,day,('jkn','shj'),1) expTaskPathShj0 = self.createExpTaskFile(expTaskTemplatePath,'author',\ year,month,day,('shj',),0) expTaskPathShj1 = self.createExpTaskFile(expTaskTemplatePath,'author',\ year,month,day,('shj','jkn'),1) # Check that the actual task file is identical to the expected actTaskPathJkn0 = self.testDir + '/../entries/' + year + '/' + month + \ '/' + day + '/' + year + month + day + '_jkn0.tex' actTaskPathJkn1 = self.testDir + '/../entries/' + year + '/' + month + \ '/' + day + '/' + year + month + day + '_jkn1.tex' actTaskPathShj0 = self.testDir + '/../entries/' + year + '/' + month + \ '/' + day + '/' + year + month + day + '_shj0.tex' actTaskPathShj1 = self.testDir + '/../entries/' + year + '/' + month + \ '/' + day + '/' + year + month + day + '_shj1.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ actTaskPathJkn0,expTaskPathJkn0)) self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ actTaskPathJkn1,expTaskPathJkn1)) self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ actTaskPathShj0,expTaskPathShj0)) self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ actTaskPathShj1,expTaskPathShj1)) # remove the generated task file os.remove(expTaskPathJkn0) os.remove(expTaskPathJkn1) os.remove(expTaskPathShj0) os.remove(expTaskPathShj1)
def testNewTemplate(self): # Generate a new task addTask.addTask(('testTag1,testTag2','This is the title of the task',\ '','review')) # Find the current date year, month, day = self.getTodayStrings() # Update the expected task file with the date label expTaskTemplatePath = self.testDir + \ '/test_add_task_files/template/review.tpl.tex' expTaskPath = self.createExpTaskFile(expTaskTemplatePath,'template',\ year,month,day,'',0) # Check that the actual task file is identical to the expected actTaskPath = self.testDir + '/../entries/' + year + '/' + month + \ '/' + day + '/' + year + month + day + '_0.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ actTaskPath,expTaskPath)) # remove the generated task file os.remove(expTaskPath)
def testSetDate(self): # Generate a new task year = '2014' month = '06' day = '01' addTask.addTask(('testTag1,testTag2','This is the title of the task',\ '','',year + '-' + month + '-' + day)) # Update the expected task file with the date label expTaskTemplatePath = self.testDir + \ '/test_add_task_files/date/default.tpl.tex' expTaskPath = self.createExpTaskFile(expTaskTemplatePath,'date',\ year,month,day,'',0) # Check that the actual task file is identical to the expected actTaskPath = self.testDir + '/../entries/' + year + '/' + month + \ '/' + day + '/' + year + month + day + '_0.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ actTaskPath,expTaskPath)) # remove the generated task file os.remove(expTaskPath)
def testChangeValidAuthorInitials(self): oldAuthorInitials = 'jkn' anotherAuthorInitials = 'jd' if sys.version_info[0] < 3: oldAuthorName = 'Jesper Kjær Nielsen'.decode('utf-8') else: oldAuthorName = 'Jesper Kjær Nielsen' anotherAuthorName = 'John Doe' oldAuthorEmail = '*****@*****.**' anotherAuthorEmail = '*****@*****.**' # Add the old author to the author database newAuthor.addAuthor2database(list((oldAuthorInitials,oldAuthorName,\ oldAuthorEmail))) newAuthor.addAuthor2database(list((anotherAuthorInitials,anotherAuthorName,\ anotherAuthorEmail))) # The new author expNewAuthorInitials = 'jd' expNewAuthorName = oldAuthorName expNewAuthorEmail = oldAuthorEmail # Change the author info changeAuthor.updateAuthor( list((oldAuthorInitials, expNewAuthorInitials))) # Check that the author info has been updated db = DiaryDatabaseWrapper.DiaryDatabaseWrapper() authorRows = db.selectFromTable('authors',('initials','name','email'),\ 'WHERE initials=\'' + expNewAuthorInitials + '\'') self.assertTrue(len(authorRows) == 1) self.assertEqual(authorRows[0][0], expNewAuthorInitials) if sys.version_info[0] < 3: self.assertEqual(authorRows[0][1], expNewAuthorName) self.assertEqual(authorRows[0][2], expNewAuthorEmail) else: self.assertEqual(authorRows[0][1], expNewAuthorName) self.assertEqual(authorRows[0][2], expNewAuthorEmail) # Check that the entries have been updated expEntry = self.testDir + \ '/test_change_author_files/author_initials/20140824_jkn0.tex' self.assertTrue(commonDiaryTestFunctions.isFileContentIdentical(\ self.entryPath,expEntry))