Esempio n. 1
0
 def test_setcolor ( self ):
     tasks = [todo.Task ( "test" ), todo.Task ( "rest" )]
     self.assertEqual ( tasks[0].coloring, "" )
     self.assertEqual ( tasks[1].coloring, "" )
     todo.setcolor ( tasks, "priority" )
     self.assertEqual ( tasks[0].coloring, "priority" )
     self.assertEqual ( tasks[1].coloring, "priority" )
Esempio n. 2
0
 def test_compare_by_date ( self ):
     T0 = todo.Task ( "test @+0d" )
     T1 = todo.Task ( "test @+1d" )
     Tn = todo.Task ( "test" )
     self.assertEqual ( todo.compare_by_date ( T0, T1 ), -1 )
     self.assertEqual ( todo.compare_by_date ( T0, T0 ), 0 )
     self.assertEqual ( todo.compare_by_date ( T1, T0 ), 1 )
     self.assertEqual ( todo.compare_by_date ( T0, Tn ), -1 )
     self.assertEqual ( todo.compare_by_date ( Tn, T0 ), 1 )
     self.assertEqual ( todo.compare_by_date ( Tn, Tn ), 0 )
Esempio n. 3
0
 def test_compare_by_project ( self ):
     Ta = todo.Task ( "test :a" )
     Tb = todo.Task ( "test :b" )
     Tn = todo.Task ( "test" )
     self.assertEqual ( todo.compare_by_project ( Ta, Tb ), -1 )
     self.assertEqual ( todo.compare_by_project ( Ta, Ta ), 0 )
     self.assertEqual ( todo.compare_by_project ( Tb, Ta ), 1 )
     self.assertEqual ( todo.compare_by_project ( Ta, Tn ), -1 )
     self.assertEqual ( todo.compare_by_project ( Tn, Ta ), 1 )
     self.assertEqual ( todo.compare_by_project ( Tn, Tn ), 0 )
Esempio n. 4
0
 def test_compare_by_priority (self):
     T1 = todo.Task ( "test +4" )
     T2 = todo.Task ( "test +3" )
     Tn = todo.Task ( "test" )
     self.assertEqual ( todo.compare_by_priority ( T1, T2 ), -1 )
     self.assertEqual ( todo.compare_by_priority ( T1, T1 ), 0 )
     self.assertEqual ( todo.compare_by_priority ( T2, T1 ), 1 )
     self.assertEqual ( todo.compare_by_priority ( T1, Tn ), -1 )
     self.assertEqual ( todo.compare_by_priority ( Tn, T1 ), 1 )
     self.assertEqual ( todo.compare_by_priority ( Tn, Tn ), 0 )
Esempio n. 5
0
 def test_check_due ( self ):
     T = todo.Task ( "test @+-1d" )
     self.assertEqual ( todo.check_due ( T ), 3 )
     T = todo.Task ( "test @+0d" )
     self.assertEqual ( todo.check_due ( T ), 2 )
     T = todo.Task ( "test @+1d" )
     self.assertEqual ( todo.check_due ( T ), 1 )
     T = todo.Task ( "test @+2w" )
     self.assertEqual ( todo.check_due ( T ), 0 )
     T = todo.Task ( "test" )
     self.assertEqual ( todo.check_due ( T ), 0 )
Esempio n. 6
0
 def test_TaskClass ( self ):
     T = todo.Task ( "test +4 @2010-10-29 :dummy" )
     self.assertEqual ( T.task, "test" )
     self.assertEqual ( T.project, "dummy" )
     self.assertEqual ( T.priority, 4 )
     self.assertEqual ( T.due, "2010-10-29" )
     self.assertEqual ( str(T), " :dummy           +4 @2010-10-29   test" )
Esempio n. 7
0
 def test_match ( self ):
     T = todo.Task ( "this is a test" )
     self.assertEqual ( T.match ( r"test" ), True )
     self.assertEqual ( T.match ( r"match" ), False )
     self.assertEqual ( T.match ( "rtest :ut" ), False )
     T = todo.Task ( "this is a test :ut" )
     self.assertEqual ( T.match ( r"test", "ut" ), True )
     self.assertEqual ( T.match ( r"test" ), True )
     self.assertEqual ( T.match ( r"test :ut" ), True )
     self.assertEqual ( T.match ( r"match", "ut" ), False )
     self.assertEqual ( T.match ( r"match :ut" ), False )
     self.assertEqual ( T.match ( r"test :not" ), False )
     self.assertEqual ( T.match ( r"test", "not" ), False )
     self.assertEqual ( T.match ( r"match", "not" ), False )
     self.assertEqual ( T.match ( r"match :not" ), False )
     self.assertEqual ( T.match ( r"match", "ut" ), False )
     self.assertEqual ( T.match ( r"match :ut" ), False )
     self.assertEqual ( T.match ( r"test :not" ), False )
     self.assertEqual ( T.match ( r"test", "not" ), False )
     self.assertEqual ( T.match ( r"match", "not" ), False )
     self.assertEqual ( T.match ( r"match :not" ), False )
Esempio n. 8
0
    def on_actionNew_Task_triggered(self, checked=None):
        if checked is None: return
        # Create a dummy task
        task = todo.Task(text="New Task")

        # Create an item reflecting the task
        item = QtGui.QTreeWidgetItem([task.text, str(task.date), ""])
        item.setCheckState(0, QtCore.Qt.Unchecked)
        item.task = task

        # Put the item in the task list
        self.ui.list.addTopLevelItem(item)
        self.ui.list.setCurrentItem(item)
        # Save it in the DB
        todo.saveData()
        # Open it with the editor
        self.ui.editor.edit(item)