コード例 #1
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_recursion(self):
     tasks = [
         Task('a id:1 after:3'),
         Task('b id:2 after:1'),
         Task('c id:3 after:2')
     ]
     results = self.search('', tasks)
     self.assertEqual(len(results), 0)
コード例 #2
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
    def test_more_parents(self):
        tasks = [Task('a id:1'), Task('b id:2'), Task('c after:1,2')]
        results = self.search('', tasks)
        self.assertEqual(len(results), 2)

        results = self.search('after:1', tasks)
        self.assertEqual(len(results), 1)
        self.assertIn('c', str(results[0]))
コード例 #3
0
ファイル: test_taskid.py プロジェクト: vonshednob/pter
 def setUp(self):
     self.sources = [
         Source(FakeSource([Task('task id:30'),
                            Task('task id:prefixed22')])),
         Source(FakeSource([Task('task id:41')]))
     ]
     self.sources[0].update_contexts_and_projects()
     self.sources[1].update_contexts_and_projects()
コード例 #4
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_all_parents_completed2(self):
     tasks = [
         Task('x a id:1'),
         Task('x b id:2'),
         Task('c id:3 after:1 after:2')
     ]
     results = self.search('done:n', tasks)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0].attr_id, ['3'])
コード例 #5
0
ファイル: test_sorting.py プロジェクト: vonshednob/pter
    def testDueSorting(self):
        tasks = [
            Task(utils.dehumanize_dates("due in a week due:+1w id:1")),
            Task(utils.dehumanize_dates("due tomorrow due:1 id:2")),
            Task(utils.dehumanize_dates("due in a month due:+1m id:3")),
            Task(utils.dehumanize_dates("(A) no due date id:4"))
        ]
        sortorder = utils.build_sort_order(common.DEFAULT_SORT_ORDER)

        tasks.sort(key=lambda t: utils.sort_fnc(t, sortorder))

        self.assertEqual(tasks[0].attr_id, ['2'])
        self.assertEqual(tasks[1].attr_id, ['1'])
        self.assertEqual(tasks[2].attr_id, ['3'])
        self.assertEqual(tasks[3].attr_id, ['4'])
コード例 #6
0
ファイル: test_sorting.py プロジェクト: vonshednob/pter
    def testOverdueSorting(self):
        tasks = [
            Task(utils.dehumanize_dates("(A) Important id:1")),
            Task(utils.dehumanize_dates("due tomorrow due:1 id:2")),
            Task(utils.dehumanize_dates("due yesterday due:-1 id:3")),
            Task(utils.dehumanize_dates("Not relevant id:4"))
        ]
        sortorder = utils.build_sort_order(common.DEFAULT_SORT_ORDER)

        tasks.sort(key=lambda t: utils.sort_fnc(t, sortorder))

        self.assertEqual(tasks[0].attr_id, ['3'])
        self.assertEqual(tasks[1].attr_id, ['2'])
        self.assertEqual(tasks[2].attr_id, ['1'])
        self.assertEqual(tasks[3].attr_id, ['4'])
コード例 #7
0
ファイル: test_pter.py プロジェクト: vonshednob/pter
    def test_update_spent(self):
        then = (datetime.datetime.now() -
                datetime.timedelta(minutes=10)).strftime(utils.DATETIME_FMT)
        task = Task(f'Something spent:1h10m tracking:{then}')

        self.assertTrue(utils.update_spent(task))
        self.assertEqual(task.attributes, {'spent': ['1h20m']})
コード例 #8
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_hide_after(self):
     tasks = [Task('a id:1'), Task('b id:2 after:1')]
     results = self.search('', tasks)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0].attr_id, ['1'])
コード例 #9
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_show_all(self):
     tasks = [Task('a id:1'), Task('b id:2 after:1')]
     results = self.search('after:', tasks)
     self.assertEqual(len(results), 2)
コード例 #10
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_no_match_not(self):
     tasks = [Task('a id:1')]
     results = self.search('not:file:nope', tasks)
     self.assertEqual(len(results), 1)
コード例 #11
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_match(self):
     tasks = [Task('a id:1')]
     results = self.search('file:test', tasks)
     self.assertEqual(len(results), 1)
コード例 #12
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_ids(self):
     tasks = [Task('a id:1'), Task('b id:2 ref:1')]
     results = self.search('id:1,2', tasks)
     self.assertEqual(len(results), 2)
コード例 #13
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_after_search(self):
     tasks = [Task('x a id:1'), Task('t id:2 after:1')]
     results = self.search('ref:1', tasks)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0].attr_id, ['2'])
コード例 #14
0
ファイル: test_taskid.py プロジェクト: vonshednob/pter
 def test_decimals(self):
     sources = [Source(FakeSource([Task('task id:9'), Task('task id:12')]))]
     sources[0].update_contexts_and_projects()
     nextid = utils.new_task_id(sources)
     self.assertEqual(nextid, '13')
コード例 #15
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_has_no_id(self):
     tasks = [Task('a id:1'), Task('b')]
     results = self.search('-id:', tasks)
     self.assertEqual(len(results), 1)
     self.assertEqual(str(results[0]), 'b')
コード例 #16
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_has_id(self):
     tasks = [Task('a id:1'), Task('b')]
     results = self.search('id:', tasks)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0].attr_id, ['1'])
コード例 #17
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_not_ids2(self):
     tasks = [Task('a id:1'), Task('b id:2 ref:1')]
     results = self.search('-id:1 -id:2', tasks)
     self.assertEqual(len(results), 0)
コード例 #18
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_not_id(self):
     tasks = [Task('a id:1'), Task('b id:2 ref:1')]
     results = self.search('-id:1', tasks)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0].attr_id, ['2'])
コード例 #19
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_parent_completed(self):
     tasks = [Task('x a id:1'), Task('b after:1 id:test')]
     results = self.search('done:n', tasks)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0].attr_id, ['test'])
コード例 #20
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_ref_not_there(self):
     tasks = [Task('a id:1'), Task('b id:2 ref:1')]
     results = self.search('ref:2', tasks)
     self.assertEqual(len(results), 0)
コード例 #21
0
ファイル: test_searcher.py プロジェクト: vonshednob/pter
 def test_ref_multiple2(self):
     tasks = [Task('a id:1'), Task('b id:2 ref:1 ref:4')]
     results = self.search('ref:4', tasks)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0].attr_id, ['2'])