[FIX] test: correct Mock of search_read
authorChristophe Simonis <chs@openerp.com>
Thu, 23 Jan 2014 17:08:36 +0000 (18:08 +0100)
committerChristophe Simonis <chs@openerp.com>
Thu, 23 Jan 2014 17:08:36 +0000 (18:08 +0100)
[IMP] search_read: build order index using dict comprehension

bzr revid: chs@openerp.com-20140123170836-4qu0ei6zucaprwxs

addons/web/controllers/main.py
addons/web/tests/test_dataset.py

index f847f77..20e552c 100644 (file)
@@ -1085,9 +1085,7 @@ class DataSet(openerpweb.Controller):
 
         records = Model.read(ids, fields or False, req.context)
 
-        index = {}
-        for r in records:
-            index[r['id']] = r
+        index = dict((r['id'], r) for r in records)
         records = [index[x] for x in ids if x in index]
 
         return {
index a6faf9e..778f23a 100644 (file)
@@ -22,6 +22,11 @@ class TestDataSetController(unittest2.TestCase):
 
     def test_regular_find(self):
         self.search.return_value = [1, 2, 3]
+        self.read.return_value = [
+            {'id': 1, 'name': 'foo'},
+            {'id': 2, 'name': 'bar'},
+            {'id': 3, 'name': 'qux'}
+        ]
 
         self.dataset.do_search_read(self.request, 'fake.model')
         self.read.assert_called_once_with(