14
14
15
15
THINGSDB = things .database .ENVIRONMENT_VARIABLE_WITH_FILEPATH # type: ignore
16
16
17
+ # AW: to be continued, helps updating the test expectations when modifying the DB
18
+ HEADINGS = 3
19
+ INBOX = 2
20
+ TRASHED_TODOS = 2
21
+ TRASHED_PROJECTS = 1
22
+ TRASHED_CANCELLED = 1
23
+ TRASHED_COMPLETED = 1
24
+ TRASHED_PROJECT_TODOS = 1
25
+ TRASHED_PROJECT_TRASHED_TODOS = 1
26
+ TRASHED = (
27
+ TRASHED_TODOS
28
+ + TRASHED_PROJECTS
29
+ + TRASHED_CANCELLED
30
+ + TRASHED_COMPLETED
31
+ + TRASHED_PROJECT_TRASHED_TODOS
32
+ )
33
+ PROJECTS = 4
34
+ UPCOMING = 1
35
+ DEADLINE_PAST = 3
36
+ DEADLINE_FUTURE = 1
37
+ DEADLINE = DEADLINE_PAST + DEADLINE_FUTURE
38
+ TODAY_PROJECTS = 1
39
+ TODAY_TASKS = 4
40
+ TODAY = TODAY_PROJECTS + TODAY_TASKS
41
+
17
42
18
43
class ThingsCase (unittest .TestCase ): # noqa: V103 pylint: disable=R0904
19
44
"""Class documentation goes here."""
@@ -62,48 +87,68 @@ def test_search(self):
62
87
# "To-Do in Heading",
63
88
# "Completed To-Do in Heading",
64
89
# "Canceled To-Do in Heading"
65
- self .assertEqual (3 , len (todos ))
90
+ self .assertEqual (HEADINGS , len (todos ))
66
91
67
92
def test_inbox (self ):
68
93
tasks = things .inbox ()
69
- self .assertEqual (2 , len (tasks ))
94
+ self .assertEqual (INBOX , len (tasks ))
70
95
71
96
def test_trashed (self ):
72
- tasks = things .trash ()
73
- self .assertEqual (5 , len (tasks ))
74
97
todos = things .todos (trashed = True )
75
- self .assertEqual (2 , len (todos ))
98
+ self .assertEqual (TRASHED_TODOS , len (todos ))
76
99
projects = things .projects (trashed = True )
77
- self .assertEqual (1 , len (projects ))
100
+ self .assertEqual (TRASHED_PROJECTS , len (projects ))
78
101
projects = things .projects (trashed = None )
79
- self .assertEqual (4 , len (projects ))
102
+ self .assertEqual (PROJECTS , len (projects ))
80
103
projects = things .trash (type = "project" )
81
- self .assertEqual (1 , len (projects ))
104
+ self .assertEqual (TRASHED_PROJECTS , len (projects ))
105
+ tasks = things .trash ()
106
+ self .assertEqual (TRASHED , len (tasks ))
82
107
83
108
projects = things .trash (type = "project" , include_items = True )
84
109
project_items = projects [0 ]["items" ]
85
- self .assertEqual (1 , len (project_items ))
110
+ self .assertEqual (TRASHED_PROJECTS , len (project_items ))
86
111
filtered_project_items = [
87
112
item for item in project_items if "in Deleted Project" in item ["title" ]
88
113
]
89
- self .assertEqual (1 , len (filtered_project_items ))
114
+ self .assertEqual (TRASHED_PROJECT_TODOS , len (filtered_project_items ))
90
115
91
116
# TK: Add this test case to the database:
92
117
# to-do with trashed = 1 and whose project also has trashed = 1.
118
+ # AW: These are actually not shown in the GUI
93
119
tasks = things .tasks (type = "to-do" , trashed = True , context_trashed = True )
94
120
self .assertEqual (0 , len (tasks ))
95
121
96
122
def test_upcoming (self ):
97
123
tasks = things .upcoming ()
98
- self .assertEqual (1 , len (tasks ))
124
+ self .assertEqual (UPCOMING , len (tasks ))
99
125
100
126
def test_deadlines (self ):
127
+ tasks = things .tasks (deadline = "past" )
128
+ self .assertEqual (DEADLINE_PAST , len (tasks ))
129
+ tasks = things .tasks (deadline = "future" )
130
+ self .assertEqual (DEADLINE_FUTURE , len (tasks ))
101
131
tasks = things .deadlines ()
102
- self .assertEqual (1 , len (tasks ))
132
+ self .assertEqual (DEADLINE , len (tasks ))
133
+ with self .assertRaises (ValueError ):
134
+ tasks = things .tasks (deadline = "invalid_value" )
103
135
104
136
def test_today (self ):
137
+ projects = things .today (type = "project" )
138
+ self .assertEqual (TODAY_PROJECTS , len (projects ))
139
+ tasks = things .today (type = "to-do" )
140
+ self .assertEqual (TODAY_TASKS , len (tasks ))
105
141
tasks = things .today ()
106
- self .assertEqual (3 , len (tasks ))
142
+ self .assertEqual (TODAY , len (tasks ))
143
+ tasks_today = [
144
+ "Upcoming To-Do in Today (yellow)" ,
145
+ "Project in Today" ,
146
+ "To-Do in Today" ,
147
+ "Repeating To-Do" ,
148
+ "Overdue Todo automatically shown in Today" ,
149
+ ]
150
+ for count , value in enumerate (tasks_today ):
151
+ self .assertEqual (value , tasks [count ]["title" ])
107
152
108
153
def test_checklist (self ):
109
154
checklist_items = things .checklist_items ("3Eva4XFof6zWb9iSfYy4ej" )
@@ -113,7 +158,7 @@ def test_checklist(self):
113
158
114
159
def test_anytime (self ):
115
160
tasks = things .anytime ()
116
- self .assertEqual (12 , len (tasks ))
161
+ self .assertEqual (14 , len (tasks ))
117
162
self .assertTrue (any (task .get ("area_title" ) == "Area 1" for task in tasks ))
118
163
119
164
def test_logbook (self ):
@@ -141,28 +186,28 @@ def test_get_by_uuid(self):
141
186
self .assertEqual (4 , len (task .keys ())) # type: ignore
142
187
143
188
def test_todos (self ):
144
- todos = things .todos (start = "Anytime" )
145
- self .assertEqual (8 , len (todos ))
146
189
todos = things .todos (start = "Anytime" , status = "completed" )
147
190
self .assertEqual (6 , len (todos ))
191
+ todos = things .todos (start = "Anytime" )
192
+ self .assertEqual (10 , len (todos ))
148
193
todos = things .todos (status = "completed" )
149
194
self .assertEqual (10 , len (todos ))
150
195
todos = things .todos (include_items = True )
151
- self .assertEqual (12 , len (todos ))
196
+ self .assertEqual (15 , len (todos ))
152
197
tasks = things .tasks (include_items = True )
153
- self .assertEqual (16 , len (tasks ))
198
+ self .assertEqual (19 , len (tasks ))
154
199
with self .assertRaises (ValueError ):
155
200
things .todos (status = "invalid_value" )
156
201
todo = things .todos ("A2oPvtt4dXoypeoLc8uYzY" )
157
202
self .assertEqual (16 , len (todo .keys ())) # type: ignore
158
203
159
204
def test_tags (self ):
205
+ tags = things .tasks (tag = "Errand" )
206
+ self .assertEqual (1 , len (tags ))
160
207
tags = things .tags ()
161
208
self .assertEqual (5 , len (tags ))
162
209
tags = things .tags (include_items = True )
163
210
self .assertEqual (5 , len (tags ))
164
- tags = things .tasks (tag = "Errand" )
165
- self .assertEqual (1 , len (tags ))
166
211
tag = things .tags (title = "Errand" )
167
212
self .assertEqual ("Errand" , tag ["title" ]) # type: ignore
168
213
@@ -174,7 +219,7 @@ def test_projects(self):
174
219
projects = things .projects ()
175
220
self .assertEqual (3 , len (projects ))
176
221
projects = things .projects (include_items = True )
177
- self .assertEqual (2 , len (projects [0 ]["items" ]))
222
+ self .assertEqual (4 , len (projects [0 ]["items" ]))
178
223
179
224
def test_areas (self ):
180
225
areas = things .areas ()
@@ -197,7 +242,7 @@ def test_last(self):
197
242
self .assertEqual (len (last_tasks ), 0 )
198
243
199
244
last_tasks = things .last ("10000w" )
200
- self .assertEqual (len (last_tasks ), 16 )
245
+ self .assertEqual (len (last_tasks ), 19 )
201
246
202
247
last_tasks = things .last ("100y" , status = "completed" )
203
248
self .assertEqual (len (last_tasks ), 10 )
0 commit comments