1
1
import copy
2
+ import subprocess
2
3
import unittest
3
4
4
5
import taskw .task
@@ -112,6 +113,9 @@ def remove_non_deterministic_keys(tasks: dict) -> dict:
112
113
task ['tags' ] = sorted (task ['tags' ])
113
114
return tasks
114
115
116
+ def get_tasks (self ) -> dict :
117
+ return self .remove_non_deterministic_keys (self .tw .load_tasks ())
118
+
115
119
def assertUpdatesEqual (self , updates : dict ):
116
120
# Make tag order deterministic.
117
121
for key in ['new' , 'existing' , 'changed' , 'closed' ]:
@@ -123,16 +127,14 @@ def assertUpdatesEqual(self, updates: dict):
123
127
self .assertEqual (self .synchronizer .updates , updates )
124
128
125
129
def test_synchronize_integration (self ):
126
- def get_tasks () -> dict :
127
- return self .remove_non_deterministic_keys (self .tw .load_tasks ())
128
130
129
131
self .assertEqual (self .tw .load_tasks (), {'completed' : [], 'pending' : []})
130
132
131
133
# TEST NEW ISSUE AND EXISTING ISSUE.
132
134
for _ in range (2 ):
133
135
db .synchronize (iter ((self .issue ,)), self .bwconfig , 'general' )
134
136
135
- self .assertEqual (get_tasks (), {
137
+ self .assertEqual (self . get_tasks (), {
136
138
'completed' : [],
137
139
'pending' : [{
138
140
'project' : 'sample_project' ,
@@ -154,7 +156,7 @@ def get_tasks() -> dict:
154
156
155
157
db .synchronize (iter ((self .issue ,)), self .bwconfig , 'general' )
156
158
157
- self .assertEqual (get_tasks (), {
159
+ self .assertEqual (self . get_tasks (), {
158
160
'completed' : [],
159
161
'pending' : [{
160
162
'priority' : 'M' ,
@@ -239,6 +241,37 @@ def test_duplicate_issues(self):
239
241
'closed' : []
240
242
})
241
243
244
+ @unittest .skipIf (
245
+ subprocess .run (['task' , '--version' ], capture_output = True ).stdout .strip () <= b'2.5.1' ,
246
+ 'https://github.com/ralphbean/bugwarrior/issues/733' )
247
+ def test_synchronize_depends_description (self ):
248
+ """
249
+ Certain versions of taskwarrior/taskw don't properly handle
250
+ descriptions that start with taskwarrior keywords.
251
+
252
+ See https://github.com/ralphbean/bugwarrior/issues/733.
253
+ """
254
+ self .issue ['description' ] = 'depends filter does not work with IDs'
255
+
256
+ # Note: In order to test the desired taskwarrior behavior we need to
257
+ # actually commit the changes to the database.
258
+ db .synchronize (iter ((self .issue ,)), self .bwconfig , 'general' )
259
+
260
+ self .assertEqual (self .get_tasks (), {
261
+ 'completed' : [],
262
+ 'pending' : [{
263
+ 'priority' : 'M' ,
264
+ 'project' : 'sample_project' ,
265
+ 'status' : 'pending' ,
266
+ 'description' : 'depends filter does not work with IDs' ,
267
+ 'githuburl' : 'https://example.com' ,
268
+ 'githubtype' : 'issue' ,
269
+ 'id' : 1 ,
270
+ 'tags' : ['foo' ],
271
+ 'urgency' : 5.7 ,
272
+ }]
273
+ })
274
+
242
275
243
276
class TestUDAs (ConfigTest ):
244
277
def test_udas (self ):
0 commit comments