Skip to content

Commit 67e4353

Browse files
committed
Pass description as positional argument.
Similarly to #134, passing description via description:{description} doesn't appear to be documented and can lead to problems. See GothenburgBitFactory/bugwarrior#733 and consider the following scenario: ```sh $ task --version 2.5.1 $ task add description:"depends filter does not work with ID" The expression could not be evaluated. $ task add "depends filter does not work with ID" Created task 1. ``` I've tried variations of the previous with various quoting and shells and have gotten the same result.
1 parent 565761c commit 67e4353

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

taskw/test/test_utils.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,25 @@ def test_ordering(self):
105105

106106
def test_taskwarrior_null_encoding_bug_workaround(self):
107107
task = {
108+
'description': 'arbitrary description',
108109
'priority': ''
109110
}
110-
actual_encoded = encode_task_experimental(task)[0]
111+
actual_encoded = encode_task_experimental(task)[1]
111112
expected_encoded = "priority:"
112113

113114
assert actual_encoded == expected_encoded
114115

115116
def test_encodes_dates(self):
116117
arbitrary_date = datetime.date(2014, 3, 2)
117118
task = {
119+
'description': 'arbitrary description',
118120
'arbitrary_field': arbitrary_date
119121
}
120122

121123
actual_encoded_task = encode_task_experimental(task)
122124
expected_encoded_task = encode_task_experimental(
123125
{
126+
'description': 'arbitrary description',
124127
'arbitrary_field': arbitrary_date.strftime(DATE_FORMAT)
125128
}
126129
)
@@ -130,12 +133,14 @@ def test_encodes_dates(self):
130133
def test_encodes_naive_datetimes(self):
131134
arbitrary_naive_datetime = datetime.datetime.now()
132135
task = {
136+
'description': 'arbitrary description',
133137
'arbitrary_field': arbitrary_naive_datetime
134138
}
135139

136140
actual_encoded_task = encode_task_experimental(task)
137141
expected_encoded_task = encode_task_experimental(
138142
{
143+
'description': 'arbitrary description',
139144
'arbitrary_field': (
140145
arbitrary_naive_datetime
141146
.replace(tzinfo=dateutil.tz.tzlocal())
@@ -152,12 +157,14 @@ def test_encodes_zoned_datetimes(self):
152157
tzinfo=arbitrary_timezone
153158
)
154159
task = {
160+
'description': 'arbitrary description',
155161
'arbitrary_field': arbitrary_zoned_datetime
156162
}
157163

158164
actual_encoded_task = encode_task_experimental(task)
159165
expected_encoded_task = encode_task_experimental(
160166
{
167+
'description': 'arbitrary description',
161168
'arbitrary_field': (
162169
arbitrary_zoned_datetime
163170
.astimezone(pytz.utc).strftime(DATE_FORMAT)

taskw/test/test_warrior.py

+9
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,12 @@ def test_add_task_recurs(self):
4949
assert tasks['pending'][0]['recur'] == 'weekly'
5050
assert tasks['pending'][0]['parent'] is not None
5151

52+
def test_add_task_depends_keyword(self):
53+
"""Add a task with description beginning with keyword "depends".
54+
See https://github.com/ralphbean/bugwarrior/issues/733.
55+
"""
56+
self.taskwarrior.task_add('depends filter does not work with IDs')
57+
tasks = self.taskwarrior.load_tasks()
58+
assert len(tasks['pending']) == 1
59+
assert (tasks['pending'][0]['description']
60+
== 'depends filter does not work with IDs')

taskw/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def encode_task_experimental(task):
134134
task[k] = encode_task_value(k, task[k])
135135

136136
# Then, format it as a string
137-
return [
137+
return [task.pop('description')] + [
138138
"%s:\"%s\"" % (k, v) if v else "%s:" % (k, )
139139
for k, v in sorted(task.items(), key=itemgetter(0))
140140
]

0 commit comments

Comments
 (0)