diff options
Diffstat (limited to 'odoo/addons/test_performance')
| -rw-r--r-- | odoo/addons/test_performance/tests/test_performance.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/odoo/addons/test_performance/tests/test_performance.py b/odoo/addons/test_performance/tests/test_performance.py index 7ea5fbcdadc..c05a62cc4d9 100644 --- a/odoo/addons/test_performance/tests/test_performance.py +++ b/odoo/addons/test_performance/tests/test_performance.py @@ -355,14 +355,26 @@ class TestPerformance(TransactionCase): ) records = self.env['test_performance.base'].search([]) self.assertEqual(len(records), 1280) + # should only cause 2 queries thanks to prefetching with self.assertQueryCount(__system__=2, demo=2): records.mapped('value') + records.invalidate_cache(['value']) + with self.assertQueryCount(__system__=2, demo=2): + records.mapped('value') + records.invalidate_cache(['value']) + with self.assertQueryCount(__system__=2, demo=2): + new_recs = records.browse(records.new(origin=record).id for record in records) + new_recs.mapped('value') + + records.invalidate_cache(['value']) with self.assertQueryCount(__system__=2, demo=2): with self.env.do_in_onchange(): records.mapped('value') + + # clean up after each pass self.env.cr.execute( 'delete from test_performance_base where id not in %s', (tuple(initial_records.ids),) |
