Merge lp:~vds/desktopcouch/fieldmapping_fixes into lp:desktopcouch

Proposed by Vincenzo Di Somma
Status: Merged
Approved by: Vincenzo Di Somma
Approved revision: 145
Merged at revision: not available
Proposed branch: lp:~vds/desktopcouch/fieldmapping_fixes
Merge into: lp:desktopcouch
Diff against target: 48 lines (+16/-4)
2 files modified
desktopcouch/records/field_registry.py (+2/-3)
desktopcouch/records/tests/test_field_registry.py (+14/-1)
To merge this branch: bzr merge lp:~vds/desktopcouch/fieldmapping_fixes
Reviewer Review Type Date Requested Status
Chad Miller (community) Approve
Eric Casteleijn (community) Approve
Martin Albisetti (community) Approve
Review via email: mp+22816@code.launchpad.net

Commit message

Making desktopcouch more robusts when dealing with mergeable lists.
If a key is still in private application annotation for a certain application but it has been removed from it's root_list the mergeable list code traces back with a key error.

Description of the change

Making desktopcouch more robusts when dealing with mergeable lists.

To post a comment you must log in.
Revision history for this message
Martin Albisetti (beuno) :
review: Approve
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Looks good, tests pass. Thanks for fixing this!

review: Approve
Revision history for this message
Chad Miller (cmiller) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'desktopcouch/records/field_registry.py'
2--- desktopcouch/records/field_registry.py 2009-07-08 17:48:11 +0000
3+++ desktopcouch/records/field_registry.py 2010-04-05 17:59:21 +0000
4@@ -118,9 +118,8 @@
5 uuid_key = self._uuidLookup(record)
6 if not uuid_key:
7 return
8- application_annotations = self.get_application_annotations(record)
9- if self._field_name in root_list._data[uuid_key]:
10- del root_list._data[uuid_key][self._field_name]
11+ if self._field_name in root_list._data.get(uuid_key, []):
12+ del root_list._data[uuid_key][self._field_name]
13
14 def setValue(self, record, value):
15 """set the value for the registered field"""
16
17=== modified file 'desktopcouch/records/tests/test_field_registry.py'
18--- desktopcouch/records/tests/test_field_registry.py 2010-01-29 22:14:25 +0000
19+++ desktopcouch/records/tests/test_field_registry.py 2010-04-05 17:59:21 +0000
20@@ -68,7 +68,7 @@
21 mapping.setValue(r, 'Fnord')
22 self.assertEqual('Fnord', mapping.getValue(r))
23
24- def test_mergeable_list_field_mapping(self):
25+ def test_mergeable_list_field_mapping0(self):
26 """Test the MergeableListFieldMapping object."""
27 record = Record(self.test_record)
28 mapping = MergeableListFieldMapping(
29@@ -76,6 +76,19 @@
30 self.assertEqual('the value', mapping.getValue(record))
31 mapping.setValue(record, 'a new value')
32 self.assertEqual('a new value', mapping.getValue(record))
33+ mapping.deleteValue(record)
34+ self.assertEqual(None, mapping.getValue(record))
35+
36+ def test_mergeable_list_field_mapping1(self):
37+ """Test the MergeableListFieldMapping object."""
38+ record = Record(self.test_record)
39+ mapping = MergeableListFieldMapping(
40+ 'Test App', 'test_field', 'test_fields', 'the_field')
41+ self.assertEqual('the value', mapping.getValue(record))
42+ del record._data['test_fields'][
43+ 'e47455fb-da05-481e-a2c7-88f14d5cc163']
44+ mapping.deleteValue(record)
45+ self.assertEqual(None, mapping.getValue(record))
46
47 def test_mergeable_list_field_mapping_empty_field(self):
48 """Test setting empty values in the MergeableListFieldMapping object."""

Subscribers

People subscribed via source and target branches