Merge lp:~dooferlad/launchpad/workitems-bugfix into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Brad Crittenden |
Approved revision: | no longer in the source branch. |
Merged at revision: | 15445 |
Proposed branch: | lp:~dooferlad/launchpad/workitems-bugfix |
Merge into: | lp:launchpad |
Diff against target: |
122 lines (+78/-10) 2 files modified
lib/lp/blueprints/model/specification.py (+27/-10) lib/lp/blueprints/model/tests/test_specification.py (+51/-0) |
To merge this branch: | bzr merge lp:~dooferlad/launchpad/workitems-bugfix |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brad Crittenden (community) | code | Approve | |
Review via email: mp+110563@code.launchpad.net |
Commit message
Bug Fix for bug #1004416. Work item editor now handles duplicate work items correctly.
Description of the change
-- Summary
Bug Fix for #1004416
The existing work item editor code assumed that work items would be uniquely identifiable by title alone. When inserting a new work item you could insert a duplicate, but any changes to it would only apply to the first work item that the code found. Deleting one of those work items would fail - you had to delete both.
-- Proposed fix
Modify logic that takes work item updates to not just use work item name as the only identifier.
-- Pre-implementation notes
None.
-- Implementation details
Since the work item editor is still a text box, the work item name is still used to identify a work item, but the code takes care to only match a work item for update or deletion once. This resolves the problems seen.
-- LOC Rationale
Added quite a few lines, though. These will be more than offset by:
https:/
-- Tests
test_duplicate_
-- Demo and Q/A
1. In a dev instance run http://
2. Visit https:/
-- Lint
None.
Hi James,
Thanks for making this change. I hadn't paid a lot of attention to the new work items feature of blueprints so it was interesting to learn a little about them.
* The logic to populate a dictionary with the count of items in a list is pretty generic and repeated. Perhaps you could factor that out into a method.
* Please change "if(" to "if (" at line 17 and elsewhere.
* I think "if not title in existing_ title_count" reads better as "if title not in existing_ title_count" , as you'd written it previously.
* In the following
if(new_ wi['title' ] not in existing_titles or wi['title' ] in existing_ title_count and title_count[ new_wi[ 'title' ]] == 0):
new_
existing_
the second line is redundant as you just established the title is in existing_titles so it must also appear in existing_ title_count.
* I know you didn't write this line, but
for i in range(len( new_work_ items)) :
new_wi = new_work_items[i]
would be easier to follow if it was done like
for i, new_wi in enumerate( new_work_ items):
* You have a typo "anotehr".
* In your test, it might be easier to understand if your duplicate items were copied from the first one, i.e.
from copy import copy
new_w1_data = dict(...)
new_w2_data = copy(new_w1_data)
...
new_w3_data = copy(new_w1_data)
A reader will know instantly what is going on without having to look at every item in the dicts to verify they are the same.
Finally I'll note this test is very busy. Ideally each test would exercise one concept. Perhaps you could break this test up into one that shows adding duplicates works and another that proves deleting will work. That separation comes at the price of refactoring or (worse) duplicate set up code.
I'd like to go ahead and mark this proposal 'Approved', pending the mentioned changes being made.
Thanks for the nice branch.