1
|
|
|
#!/usr/bin/env python3 |
2
|
|
|
# -*- coding: utf-8 -*- |
3
|
|
|
|
4
|
|
|
"""Module documentation goes here.""" |
5
|
|
|
|
6
|
|
|
import unittest |
7
|
|
|
from things3.things3 import Things3 |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
class Things3Case(unittest.TestCase): |
11
|
|
|
"""Class documentation goes here.""" |
12
|
|
|
|
13
|
|
|
def setUp(self): |
14
|
|
|
self.things3 = Things3(database='resources/demo.sqlite3') |
15
|
|
|
|
16
|
|
|
def test_today(self): |
17
|
|
|
"""Test Today.""" |
18
|
|
|
tasks = self.things3.get_today() |
19
|
|
|
self.assertEqual(2, len(tasks)) |
20
|
|
|
titles = [] |
21
|
|
|
for task in tasks: |
22
|
|
|
titles.append(task['title']) |
23
|
|
|
self.assertIn("Today MIT task without a project", titles) |
24
|
|
|
self.assertIn("Today items are shown here", titles) |
25
|
|
|
|
26
|
|
|
def test_inbox(self): |
27
|
|
|
"""Test Inbox.""" |
28
|
|
|
tasks = self.things3.get_inbox() |
29
|
|
|
self.assertEqual(3, len(tasks)) |
30
|
|
|
titles = [] |
31
|
|
|
for task in tasks: |
32
|
|
|
titles.append(task['title']) |
33
|
|
|
self.assertIn("Currently Things 3 tasks are supported", titles) |
34
|
|
|
self.assertIn("This is a demo setup", titles) |
35
|
|
|
self.assertIn("New tasks are shown here", titles) |
36
|
|
|
|
37
|
|
|
def test_upcoming(self): |
38
|
|
|
"""Test Upcoming.""" |
39
|
|
|
tasks = self.things3.get_upcoming() |
40
|
|
|
self.assertEqual(5, len(tasks)) |
41
|
|
|
titles = [] |
42
|
|
|
for task in tasks: |
43
|
|
|
titles.append(task['title']) |
44
|
|
|
self.assertIn("Waiting for this...", titles) |
45
|
|
|
|
46
|
|
|
def test_next(self): |
47
|
|
|
"""Test Next.""" |
48
|
|
|
tasks = self.things3.get_anytime() |
49
|
|
|
self.assertEqual(30, len(tasks)) |
50
|
|
|
|
51
|
|
|
# def test_backlog(self): |
52
|
|
|
# """Test Backlog.""" |
53
|
|
|
# tasks = self.things3.get_someday() |
54
|
|
|
# self.assertEqual(1, len(tasks)) |
55
|
|
|
|
56
|
|
|
def test_waiting(self): |
57
|
|
|
"""Test Waiting.""" |
58
|
|
|
tasks = self.things3.get_waiting() |
59
|
|
|
self.assertEqual(3, len(tasks)) |
60
|
|
|
|
61
|
|
|
def test_mit(self): |
62
|
|
|
"""Test MIT.""" |
63
|
|
|
tasks = self.things3.get_mit() |
64
|
|
|
self.assertEqual(5, len(tasks)) |
65
|
|
|
|
66
|
|
|
def test_completed(self): |
67
|
|
|
"""Test completed tasks.""" |
68
|
|
|
tasks = self.things3.get_completed() |
69
|
|
|
self.assertEqual(3, len(tasks)) |
70
|
|
|
|
71
|
|
|
def test_cancelled(self): |
72
|
|
|
"""Test cancelled tasks.""" |
73
|
|
|
tasks = self.things3.get_cancelled() |
74
|
|
|
self.assertEqual(2, len(tasks)) |
75
|
|
|
|
76
|
|
|
def test_trashed(self): |
77
|
|
|
"""Test trashed tasks.""" |
78
|
|
|
tasks = self.things3.get_trashed() |
79
|
|
|
self.assertEqual(10, len(tasks)) |
80
|
|
|
|
81
|
|
|
def test_all(self): |
82
|
|
|
"""Test all tasks.""" |
83
|
|
|
tasks = self.things3.get_all() |
84
|
|
|
self.assertEqual(55, len(tasks)) |
85
|
|
|
|
86
|
|
|
def test_due(self): |
87
|
|
|
"""Test due tasks.""" |
88
|
|
|
tasks = self.things3.get_due() |
89
|
|
|
self.assertEqual(1, len(tasks)) |
90
|
|
|
|
91
|
|
|
def test_lint(self): |
92
|
|
|
"""Test tasks that should be cleaned up.""" |
93
|
|
|
tasks = self.things3.get_lint() |
94
|
|
|
self.assertEqual(4, len(tasks)) |
95
|
|
|
|
96
|
|
|
def test_empty_projects(self): |
97
|
|
|
"""Test projects that are emptÿ.""" |
98
|
|
|
tasks = self.things3.get_empty_projects() |
99
|
|
|
self.assertEqual(2, len(tasks)) |
100
|
|
|
|
101
|
|
|
def test_cleanup(self): |
102
|
|
|
"""Test tasks that should be cleaned up.""" |
103
|
|
|
tasks = self.things3.get_cleanup() |
104
|
|
|
self.assertEqual(7, len(tasks)) |
105
|
|
|
|
106
|
|
|
def test_get_projects(self): |
107
|
|
|
"""Test get projects.""" |
108
|
|
|
projects = self.things3.get_projects() |
109
|
|
|
self.assertEqual(7, len(projects)) |
110
|
|
|
|
111
|
|
|
def test_get_areas(self): |
112
|
|
|
"""Test get areas.""" |
113
|
|
|
areas = self.things3.get_areas() |
114
|
|
|
self.assertEqual(1, len(areas)) |
115
|
|
|
|
116
|
|
|
def test_get_minutes_today(self): |
117
|
|
|
"""Test get minutes today.""" |
118
|
|
|
minutes = self.things3.get_minutes_today() |
119
|
|
|
self.assertEqual([{'minutes': 35}], minutes) |
120
|
|
|
|
121
|
|
|
def test_anonymize(self): |
122
|
|
|
"""Test anonymized tasks.""" |
123
|
|
|
tasks = self.things3.get_today() |
124
|
|
|
task = tasks.pop() |
125
|
|
|
self.things3.anonymize = True |
126
|
|
|
tasks = self.things3.get_today() |
127
|
|
|
self.assertNotEqual(tasks.pop(), task) |
128
|
|
|
|
129
|
|
|
|
130
|
|
|
if __name__ == '__main__': |
131
|
|
|
unittest.main() |
132
|
|
|
|