Пример #1
0
 def test_two_tasks(self):
     task1 = 'do something +project1 @context1'
     task2 = '(A) do something else +project1 @context2'
     self.file.tasks.extend([Task(task1), Task(task2)])
     self.saveAndReload()
     self.assertEqual(self.file.tasks[0].text, task2)
     self.assertEqual(self.file.tasks[1].text, task1)
Пример #2
0
 def test_get_all_projects(self):
     self.file.tasks.extend([
         Task('x task with +project1'),
         Task('task with +project2'),
         Task('task with +project1 and +project2'),
         Task('task with +project1 and +project2 and +project3')
     ])
     self.saveAndReload()
     self.assertEqual(self.file.getAllProjects(), {'project1': 2, 'project2': 3, 'project3': 1})
Пример #3
0
 def test_get_all_completed_contexts(self):
     self.file.tasks.extend([
         Task('x task with @context1'),
         Task('task with @context2'),
         Task('task with @context1 and @context2'),
         Task('x task with @context1 and @context2 and @context3')
     ])
     self.saveAndReload()
     self.assertEqual(self.file.getAllCompletedContexts(), {'context1': 2, 'context2': 1, 'context3': 1})
Пример #4
0
 def test_five_tasks(self):
     task1 = Task('do something +project1 @context1')
     task2 = Task('(A) do something else +project1 @context2')
     task3 = Task('do something else +project1 @context2')
     task4 = Task('something else +project1 @context2')
     task5 = Task('abc +project1 @context2')
     self.file.tasks.extend([task1, task2, task3, task4, task5])
     self.saveAndReload()
     self.assertEqual(self.file.tasks[0].text, task2.text)
     self.assertEqual(self.file.tasks[1].text, task5.text)
     self.assertEqual(self.file.tasks[2].text, task1.text)
     self.assertEqual(self.file.tasks[3].text, task3.text)
     self.assertEqual(self.file.tasks[4].text, task4.text)
Пример #5
0
    def test_get_all_due_ranges(self):
        today = date.today().strftime('%Y-%m-%d')
        yesterday = (date.today() - timedelta(days = 1)).strftime('%Y-%m-%d')

        self.file.tasks.extend([
            Task('x due:' + today + ' completed task of today'),
            Task('due:' + today + ' first task of today'),
            Task('due:' + today + ' second task of today'),
            Task('due:' + yesterday + ' task of yesterday'),
        ])
        self.saveAndReload()
        self.assertEqual(self.file.getAllDueRanges()[0], {'Today': 2, 'This week': 2, 'This month': 2, 'Overdue': 1})
        self.assertIsInstance(self.file.getAllDueRanges()[1], dict)
Пример #6
0
 def _createTasksFromLines(self, lines):
     self.tasks = []
     for line in lines:
         task_text = line.strip()
         if task_text:
             task = Task(task_text)
             self.tasks.append(task)
Пример #7
0
 def test_single_task(self):
     text = 'due:1999-10-10 do something +project1 @context1'
     self.file.tasks.append(Task(text))
     self.saveAndReload()
     self.assertEqual(self.file.tasks[0].text, text)
     self.assertEqual(self.file.tasks[0].contexts, ['context1'])
     self.assertEqual(self.file.tasks[0].projects, ['project1'])
     self.assertEqual(self.file.tasks[0].is_complete, False)
     self.assertEqual(self.file.tasks[0].priority, None)
     self.assertEqual(self.file.tasks[0].due,'1999-10-10')
Пример #8
0
 def test(self):
     self.assertEqual(Task('task1').is_complete, Task('task2').is_complete)
     self.assertEqual(
         Task('x task1').is_complete,
         Task('x task2').is_complete)
     self.assertNotEqual(
         Task('task').is_complete,
         Task('x task').is_complete)
     self.assertNotEqual(
         Task('x task').is_complete,
         Task('task').is_complete)
     self.assertGreater(
         Task('task').is_complete,
         Task('x task').is_complete)
     self.assertLess(Task('x task').is_complete, Task('task').is_complete)
Пример #9
0
    def test(self):
        self.assertEqual(Task('task'), Task('task'))
        self.assertEqual(Task('(A) task'), Task('(A) task'))

        self.assertLess(Task('task1'), Task('task2'))
        self.assertLess(Task('task'), Task('x task'))
        self.assertLess(Task('(A) task'), Task('(B) task'))
        self.assertLess(Task('(A) task'), Task('task'))
        self.assertLess(Task('(A) task'), Task('x (A) task'))

        self.assertGreater(Task('task2'), Task('task1'))
        self.assertGreater(Task('x task'), Task('task'))
        self.assertGreater(Task('(B) task'), Task('(A) task'))
        self.assertGreater(Task('task'), Task('(A) task'))
        self.assertGreater(Task('x (A) task'), Task('(A) task'))
Пример #10
0
 def test(self):
     self.assertEqual(Task('task1').priority, Task('task2').priority)
     self.assertEqual(
         Task('(A) task1').priority,
         Task('(A) task2').priority)
     self.assertNotEqual(Task('(A) task').priotity, Task('task'))
     self.assertGreater(Task('(A) task'.priority,
                             Task('(B) task').priority))
     self.assertGreater(Task('(Z) task'.priority), Task('task').priority)
     self.assertLess(Task('(B) task'.priority, Task('(A) task').priority))
     self.assertLess(Task('task').priority, Task('(Z) task'.priority))
     self.assertNotEqual(
         Task('(A) task1').priority,
         Task('(AA) task2').priority)
     self.assertNotEqual(
         Task('(1) task1').priority,
         Task('(1) task2').priority)