Merge lp:~linaro-infrastructure/launchpad/fix-work-item-brackets into lp:launchpad

Proposed by Mattias Backman
Status: Merged
Approved by: Stuart Bishop
Approved revision: no longer in the source branch.
Merged at revision: 14965
Proposed branch: lp:~linaro-infrastructure/launchpad/fix-work-item-brackets
Merge into: lp:launchpad
Diff against target: 59 lines (+37/-1)
2 files modified
lib/lp/services/fields/__init__.py (+1/-1)
lib/lp/services/fields/tests/test_fields.py (+36/-0)
To merge this branch: bzr merge lp:~linaro-infrastructure/launchpad/fix-work-item-brackets
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+97584@code.launchpad.net

Commit message

[r=stub] Fix work items parsing.

Description of the change

This branch makes the work items parsing handle assigned work items that have square brackets in the title.

The problem was fixed by making the parse regexp not greedy.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Fine

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/services/fields/__init__.py'
--- lib/lp/services/fields/__init__.py 2012-03-08 14:18:12 +0000
+++ lib/lp/services/fields/__init__.py 2012-03-15 08:37:21 +0000
@@ -114,7 +114,7 @@
114MILESTONE_RE = re.compile('^work items(.*)\s*:\s*$', re.I)114MILESTONE_RE = re.compile('^work items(.*)\s*:\s*$', re.I)
115# Regexp for work items.115# Regexp for work items.
116WORKITEM_RE = re.compile(116WORKITEM_RE = re.compile(
117 '^(\[(?P<assignee>.*)\])?\s*(?P<title>.*)\s*:\s*(?P<status>.*)\s*$', re.I)117 '^(\[(?P<assignee>.*?)\])?\s*(?P<title>.*)\s*:\s*(?P<status>.*)\s*$', re.I)
118118
119119
120# Field Interfaces120# Field Interfaces
121121
=== modified file 'lib/lp/services/fields/tests/test_fields.py'
--- lib/lp/services/fields/tests/test_fields.py 2012-03-08 14:18:12 +0000
+++ lib/lp/services/fields/tests/test_fields.py 2012-03-15 08:37:21 +0000
@@ -244,6 +244,42 @@
244 LaunchpadValidationError, self.field.parseLine,244 LaunchpadValidationError, self.field.parseLine,
245 '[test-person] :TODO')245 '[test-person] :TODO')
246246
247 def test_assignee_and_bracket(self):
248 title = "Work item with one ] bracket"
249 work_items_text = ("Work items:\n"
250 "[person] %s: TODO" % title)
251 parsed = self.field.parse(work_items_text)
252 self.assertEqual(
253 parsed, [{'title': title,
254 'status': 'TODO',
255 'assignee': 'person',
256 'milestone': None,
257 'sequence': 0}])
258
259 def test_assignee_and_brackets(self):
260 title = "Work item with two [2] brackets"
261 work_items_text = ("Work items:\n"
262 "[person] %s: TODO" % title)
263 parsed = self.field.parse(work_items_text)
264 self.assertEqual(
265 parsed, [{'title': title,
266 'status': 'TODO',
267 'assignee': 'person',
268 'milestone': None,
269 'sequence': 0}])
270
271 def test_no_assignee_and_brackets(self):
272 title = "Work item with [] brackets"
273 work_items_text = ("Work items:\n"
274 "%s: TODO" % title)
275 parsed = self.field.parse(work_items_text)
276 self.assertEqual(
277 parsed, [{'title': title,
278 'status': 'TODO',
279 'assignee': None,
280 'milestone': None,
281 'sequence': 0}])
282
247 def test_multi_line_parsing(self):283 def test_multi_line_parsing(self):
248 title_1 = 'Work item 1'284 title_1 = 'Work item 1'
249 title_2 = 'Work item 2'285 title_2 = 'Work item 2'