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
|
|
|
FILEPATH = dict(filepath="resources/demo.sqlite3") |
14
|
|
|
|
15
|
|
|
def setUp(self): |
16
|
|
|
self.things3 = Things3(database="resources/demo.sqlite3") |
17
|
|
|
self.things3.tag_mit = "😀" |
18
|
|
|
self.things3.tag_waiting = "Waiting" |
19
|
|
|
self.things3.tag_cleanup = "Cleanup" |
20
|
|
|
self.things3.tag_seinfeld = "Seinfeld" |
21
|
|
|
self.things3.tag_a = "A" |
22
|
|
|
self.things3.tag_b = "B" |
23
|
|
|
self.things3.tag_c = "C" |
24
|
|
|
self.things3.tag_d = "D" |
25
|
|
|
self.things3.stat_days = 365 |
26
|
|
|
|
27
|
|
|
def test_today(self): |
28
|
|
|
"""Test Today.""" |
29
|
|
|
tasks = self.things3.get_today() |
30
|
|
|
self.assertEqual(5, len(tasks)) |
31
|
|
|
titles = [] |
32
|
|
|
for task in tasks: |
33
|
|
|
titles.append(task["title"]) |
34
|
|
|
self.assertIn("Today MIT task without a project", titles) |
35
|
|
|
self.assertIn("Today items are shown here", titles) |
36
|
|
|
|
37
|
|
|
def test_inbox(self): |
38
|
|
|
"""Test Inbox.""" |
39
|
|
|
tasks = self.things3.get_inbox() |
40
|
|
|
self.assertEqual(3, len(tasks)) |
41
|
|
|
titles = [] |
42
|
|
|
for task in tasks: |
43
|
|
|
titles.append(task["title"]) |
44
|
|
|
self.assertIn("Currently Things 3 tasks are supported", titles) |
45
|
|
|
self.assertIn("This is a demo setup", titles) |
46
|
|
|
self.assertIn("New tasks are shown here", titles) |
47
|
|
|
|
48
|
|
|
def test_upcoming(self): |
49
|
|
|
"""Test Upcoming.""" |
50
|
|
|
tasks = self.things3.get_upcoming() |
51
|
|
|
self.assertEqual(5, len(tasks)) |
52
|
|
|
# things.py: was 6 in old version |
53
|
|
|
titles = [] |
54
|
|
|
for task in tasks: |
55
|
|
|
titles.append(task["title"]) |
56
|
|
|
self.assertIn("Waiting for this...", titles) |
57
|
|
|
|
58
|
|
|
def test_next(self): |
59
|
|
|
"""Test Next.""" |
60
|
|
|
tasks = self.things3.get_anytime() |
61
|
|
|
self.assertEqual(32, len(tasks)) |
62
|
|
|
|
63
|
|
|
# def test_backlog(self): |
64
|
|
|
# """Test Backlog.""" |
65
|
|
|
# tasks = self.things3.get_someday() |
66
|
|
|
# self.assertEqual(1, len(tasks)) |
67
|
|
|
|
68
|
|
|
def test_waiting(self): |
69
|
|
|
"""Test Waiting.""" |
70
|
|
|
tasks = self.things3.get_waiting() |
71
|
|
|
self.assertEqual(3, len(tasks)) |
72
|
|
|
|
73
|
|
|
def test_mit(self): |
74
|
|
|
"""Test MIT.""" |
75
|
|
|
tasks = self.things3.get_mit() |
76
|
|
|
self.assertEqual(8, len(tasks)) |
77
|
|
|
|
78
|
|
|
def test_completed(self): |
79
|
|
|
"""Test completed tasks.""" |
80
|
|
|
tasks = self.things3.get_completed() |
81
|
|
|
self.assertEqual(3, len(tasks)) |
82
|
|
|
|
83
|
|
|
def test_cancelled(self): |
84
|
|
|
"""Test cancelled tasks.""" |
85
|
|
|
tasks = self.things3.get_cancelled() |
86
|
|
|
self.assertEqual(2, len(tasks)) |
87
|
|
|
|
88
|
|
|
def test_trashed(self): |
89
|
|
|
"""Test trashed tasks.""" |
90
|
|
|
tasks = self.things3.get_trashed() |
91
|
|
|
self.assertEqual(10, len(tasks)) |
92
|
|
|
|
93
|
|
|
def test_all(self): |
94
|
|
|
"""Test all tasks.""" |
95
|
|
|
tasks = self.things3.get_all() |
96
|
|
|
self.assertEqual(54, len(tasks)) |
97
|
|
|
|
98
|
|
|
def test_due(self): |
99
|
|
|
"""Test due tasks.""" |
100
|
|
|
tasks = self.things3.get_due() |
101
|
|
|
self.assertEqual(1, len(tasks)) |
102
|
|
|
|
103
|
|
|
def test_lint(self): |
104
|
|
|
"""Test tasks that should be cleaned up.""" |
105
|
|
|
tasks = self.things3.get_lint() |
106
|
|
|
self.assertEqual(4, len(tasks)) |
107
|
|
|
|
108
|
|
|
def test_empty_projects(self): |
109
|
|
|
"""Test projects that are emptÿ.""" |
110
|
|
|
tasks = self.things3.get_empty_projects() |
111
|
|
|
self.assertEqual(2, len(tasks)) |
112
|
|
|
|
113
|
|
|
def test_cleanup(self): |
114
|
|
|
"""Test tasks that should be cleaned up.""" |
115
|
|
|
tasks = self.things3.get_cleanup() |
116
|
|
|
self.assertEqual(8, len(tasks)) |
117
|
|
|
# things.py: was 7 in old version - new lib returns a duplicate? |
118
|
|
|
|
119
|
|
|
def test_get_projects(self): |
120
|
|
|
"""Test get projects.""" |
121
|
|
|
projects = self.things3.get_projects() |
122
|
|
|
self.assertEqual(8, len(projects)) |
123
|
|
|
self.assertEqual(2, projects.pop()["size"]) |
124
|
|
|
|
125
|
|
|
def test_get_areas(self): |
126
|
|
|
"""Test get areas.""" |
127
|
|
|
areas = self.things3.get_areas() |
128
|
|
|
self.assertEqual(1, len(areas)) |
129
|
|
|
self.assertEqual(2, areas.pop()["size"]) |
130
|
|
|
|
131
|
|
|
def test_get_minutes_today(self): |
132
|
|
|
"""Test get minutes today.""" |
133
|
|
|
minutes = self.things3.get_minutes_today() |
134
|
|
|
self.assertEqual([{"minutes": 35}], minutes) |
135
|
|
|
|
136
|
|
|
# @unittest.skip(reason="not migrated to new lib") |
137
|
|
|
def test_anonymize(self): |
138
|
|
|
"""Test anonymized tasks.""" |
139
|
|
|
tasks = self.things3.get_today() |
140
|
|
|
task = tasks.pop() |
141
|
|
|
self.things3.anonymize = True |
142
|
|
|
tasks = self.things3.get_today() |
143
|
|
|
self.assertNotEqual(tasks.pop(), task) |
144
|
|
|
|
145
|
|
|
|
146
|
|
|
if __name__ == "__main__": |
147
|
|
|
unittest.main() |
148
|
|
|
|