[IMP] test_mail: add query count test record_name in message_format
This will count the number of query when formating messages, in particular for the thread name query that is changed in the following commit. Part of task-2411715 X-original-commit: 45b51acc35188765270a0b8b1dcaf5508408edf6
This commit is contained in:
committed by
Sébastien Theys
parent
43232259bf
commit
7b7483f3ed
@@ -832,6 +832,32 @@ class TestMailComplexPerformance(BaseMailPerformance):
|
||||
for message in res:
|
||||
self.assertEqual(len(message['attachment_ids']), 2)
|
||||
|
||||
@mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
|
||||
@users('emp')
|
||||
@warmup
|
||||
def test_message_format_group_thread_name_by_model(self):
|
||||
"""Ensures the fetch of multiple thread names is grouped by model."""
|
||||
records = []
|
||||
for i in range(5):
|
||||
records.append(self.env['mail.test.simple'].create({'name': 'Test'}))
|
||||
records.append(self.env['mail.test.track'].create({'name': 'Test'}))
|
||||
|
||||
messages = self.env['mail.message'].create([{
|
||||
'model': record._name,
|
||||
'res_id': record.id
|
||||
} for record in records])
|
||||
|
||||
with self.assertQueryCount(emp=5):
|
||||
res = messages.message_format()
|
||||
self.assertEqual(len(res), 6)
|
||||
|
||||
messages.flush()
|
||||
messages.invalidate_cache()
|
||||
|
||||
with self.assertQueryCount(emp=13):
|
||||
res = messages.message_format()
|
||||
self.assertEqual(len(res), 6)
|
||||
|
||||
|
||||
@tagged('mail_performance')
|
||||
class TestMailHeavyPerformancePost(BaseMailPerformance):
|
||||
|
||||
Reference in New Issue
Block a user