summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_performance.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2018-07-23 10:47:19 +0200
committerRaphael Collet <rco@odoo.com>2018-08-23 21:38:57 +0200
commit2f7c03d9ca5809b65dc6eaa778064668d34fcd2e (patch)
tree1d3452d9a127de1396563ab3b5f70de6e2bd5a7f /addons/test_mail/tests/test_performance.py
parent7ba9acea188a08a75ab1cd4a7f5f56e0d0f956ef (diff)
[IMP] base: add regular user admin as uid 2
User 1 simply becomes a technical user (inactive, no password).
Diffstat (limited to 'addons/test_mail/tests/test_performance.py')
-rw-r--r--addons/test_mail/tests/test_performance.py129
1 files changed, 64 insertions, 65 deletions
diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py
index 4320f89eaab..7b170ef2c31 100644
--- a/addons/test_mail/tests/test_performance.py
+++ b/addons/test_mail/tests/test_performance.py
@@ -26,14 +26,14 @@ class TestMailPerformance(TransactionCase):
'groups_id': [(6, 0, [self.env.ref('base.group_user').id])],
})
- @users('admin', 'demo')
+ @users('__system__', 'demo')
@warmup
def test_read_mail(self):
""" Read records inheriting from 'mail.thread'. """
records = self.env['test_performance.mail'].search([])
self.assertEqual(len(records), 5)
- with self.assertQueryCount(admin=3, demo=3):
+ with self.assertQueryCount(__system__=3, demo=3):
# without cache
for record in records:
record.partner_id.country_id.name
@@ -48,27 +48,27 @@ class TestMailPerformance(TransactionCase):
for record in records:
record.value_pc
- @users('admin', 'demo')
+ @users('__system__', 'demo')
@warmup
def test_write_mail(self):
""" Write records inheriting from 'mail.thread' (no recomputation). """
records = self.env['test_performance.mail'].search([])
self.assertEqual(len(records), 5)
- with self.assertQueryCount(admin=3, demo=3): # test_mail only: 3 - 3
+ with self.assertQueryCount(__system__=3, demo=3): # test_mail only: 3 - 3
records.write({'name': 'X'})
- @users('admin', 'demo')
+ @users('__system__', 'demo')
@warmup
def test_write_mail_with_recomputation(self):
""" Write records inheriting from 'mail.thread' (with recomputation). """
records = self.env['test_performance.mail'].search([])
self.assertEqual(len(records), 5)
- with self.assertQueryCount(admin=5, demo=5): # test_mail only: 5 - 5
+ with self.assertQueryCount(__system__=5, demo=5): # test_mail only: 5 - 5
records.write({'value': 42})
- @users('admin', 'demo')
+ @users('__system__', 'demo')
@warmup
def test_write_mail_with_tracking(self):
""" Write records inheriting from 'mail.thread' (with field tracking). """
@@ -79,36 +79,36 @@ class TestMailPerformance(TransactionCase):
'partner_id': self.env.ref('base.res_partner_12').id,
})
- with self.assertQueryCount(admin=5, demo=5): # test_mail only: 5 - 5
+ with self.assertQueryCount(__system__=5, demo=5): # test_mail only: 5 - 5
record.track = 'X'
- @users('admin', 'demo')
+ @users('__system__', 'demo')
@warmup
def test_create_mail(self):
""" Create records inheriting from 'mail.thread' (without field tracking). """
model = self.env['test_performance.mail']
- with self.assertQueryCount(admin=3, demo=3): # test_mail only: 3 - 3
+ with self.assertQueryCount(__system__=3, demo=3): # test_mail only: 3 - 3
model.with_context(tracking_disable=True).create({'name': 'X'})
- @users('admin', 'demo')
+ @users('__system__', 'demo')
@warmup
def test_create_mail_with_tracking(self):
""" Create records inheriting from 'mail.thread' (with field tracking). """
- with self.assertQueryCount(admin=13, demo=13): # test_mail only: 13 - 13
+ with self.assertQueryCount(__system__=13, demo=13): # test_mail only: 13 - 13
self.env['test_performance.mail'].create({'name': 'X'})
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_create_mail_simple(self):
- with self.assertQueryCount(admin=8, emp=8): # test_mail only: 8 - 8
+ with self.assertQueryCount(__system__=8, emp=8): # test_mail only: 8 - 8
self.env['mail.test.simple'].create({'name': 'Test'})
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_write_mail_simple(self):
rec = self.env['mail.test.simple'].create({'name': 'Test'})
- with self.assertQueryCount(admin=1, emp=1): # test_mail only: 1 - 1
+ with self.assertQueryCount(__system__=1, emp=1): # test_mail only: 1 - 1
rec.write({
'name': 'Test2',
'email_from': 'test@test.com',
@@ -149,15 +149,15 @@ class TestAdvMailPerformance(TransactionCase):
# automatically follow activities, for backward compatibility concerning query count
self.env.ref('mail.mt_activities').write({'default': True})
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_adv_activity(self):
model = self.env['mail.test.activity']
- with self.assertQueryCount(admin=9, emp=8): # test_mail only: 8 - 8
+ with self.assertQueryCount(__system__=9, emp=8): # test_mail only: 8 - 8
model.create({'name': 'Test'})
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
@mute_logger('odoo.models.unlink')
def test_adv_activity_full(self):
@@ -166,7 +166,7 @@ class TestAdvMailPerformance(TransactionCase):
'default_res_model': 'mail.test.activity',
})
- with self.assertQueryCount(admin=10, emp=15): # test_mail only: 9 - 13
+ with self.assertQueryCount(__system__=10, emp=15): # test_mail only: 9 - 13
activity = MailActivity.create({
'summary': 'Test Activity',
'res_id': record.id,
@@ -176,16 +176,16 @@ class TestAdvMailPerformance(TransactionCase):
#voip module read activity_type during create leading to one less query in enterprise on action_feedback
category = activity.activity_type_id.category
- with self.assertQueryCount(admin=26, emp=46): # test_mail only: 27 - 47
+ with self.assertQueryCount(__system__=26, emp=46): # test_mail only: 27 - 47
activity.action_feedback(feedback='Zizisse Done !')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
@mute_logger('odoo.models.unlink')
def test_adv_activity_mixin(self):
record = self.env['mail.test.activity'].create({'name': 'Test'})
- with self.assertQueryCount(admin=10, emp=15): # test_mail only: 9 - 13
+ with self.assertQueryCount(__system__=10, emp=15): # test_mail only: 9 - 13
activity = record.action_start('Test Start')
#read activity_type to normalize cache between enterprise and community
#voip module read activity_type during create leading to one less query in enterprise on action_close
@@ -193,60 +193,60 @@ class TestAdvMailPerformance(TransactionCase):
record.write({'name': 'Dupe write'})
- with self.assertQueryCount(admin=28, emp=48): # test_mail only: 29 - 49
+ with self.assertQueryCount(__system__=28, emp=48): # test_mail only: 29 - 49
record.action_close('Dupe feedback')
self.assertEqual(record.activity_ids, self.env['mail.activity'])
@mute_logger('odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_message_assignation_email(self):
self.user_test.write({'notification_type': 'email'})
record = self.env['mail.test.track'].create({'name': 'Test'})
- with self.assertQueryCount(admin=56, emp=75): # com runbot: 56 - 75 // test_mail only: 56 - 75
+ with self.assertQueryCount(__system__=56, emp=75): # com runbot: 56 - 75 // test_mail only: 56 - 75
record.write({
'user_id': self.user_test.id,
})
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_message_assignation_inbox(self):
record = self.env['mail.test.track'].create({'name': 'Test'})
- with self.assertQueryCount(admin=36, emp=47): # test_mail only: 43 - 54
+ with self.assertQueryCount(__system__=36, emp=47): # test_mail only: 43 - 54
record.write({
'user_id': self.user_test.id,
})
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_message_log(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
- with self.assertQueryCount(admin=2, emp=2): # test_mail only: 2 - 2
+ with self.assertQueryCount(__system__=2, emp=2): # test_mail only: 2 - 2
record._message_log(
body='<p>Test _message_log</p>',
message_type='comment')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_message_log_with_post(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
- with self.assertQueryCount(admin=7, emp=13): # test_mail only: 7 - 13
+ with self.assertQueryCount(__system__=7, emp=13): # test_mail only: 7 - 13
record.message_post(
body='<p>Test message_post as log</p>',
subtype='mail.mt_note',
message_type='comment')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_message_post_no_notification(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
- with self.assertQueryCount(admin=7, emp=13): # test_mail only: 7 - 13
+ with self.assertQueryCount(__system__=7, emp=13): # test_mail only: 7 - 13
record.message_post(
body='<p>Test Post Performances basic</p>',
partner_ids=[],
@@ -254,24 +254,24 @@ class TestAdvMailPerformance(TransactionCase):
subtype='mail.mt_comment')
@mute_logger('odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_message_post_one_email_notification(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
- with self.assertQueryCount(admin=48, emp=68): # com runbot: 45 - 65 // test_mail only: 48 - 68
+ with self.assertQueryCount(__system__=48, emp=68): # com runbot: 45 - 65 // test_mail only: 48 - 68
record.message_post(
body='<p>Test Post Performances with an email ping</p>',
partner_ids=self.customer.ids,
message_type='comment',
subtype='mail.mt_comment')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_message_post_one_inbox_notification(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
- with self.assertQueryCount(admin=31, emp=42): # com runbot 30 - 41 // test_mail only: 31 - 42
+ with self.assertQueryCount(__system__=31, emp=42): # com runbot 30 - 41 // test_mail only: 31 - 42
record.message_post(
body='<p>Test Post Performances with an inbox ping</p>',
partner_ids=self.user_test.partner_id.ids,
@@ -279,28 +279,28 @@ class TestAdvMailPerformance(TransactionCase):
subtype='mail.mt_comment')
@mute_logger('odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_message_subscribe_default(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
- with self.assertQueryCount(admin=7, emp=7): # test_mail only: 6 - 6
+ with self.assertQueryCount(__system__=7, emp=7): # test_mail only: 6 - 6
record.message_subscribe(partner_ids=self.user_test.partner_id.ids)
- with self.assertQueryCount(admin=3, emp=3): # test_mail only: 2 - 2
+ with self.assertQueryCount(__system__=3, emp=3): # test_mail only: 2 - 2
record.message_subscribe(partner_ids=self.user_test.partner_id.ids)
@mute_logger('odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_message_subscribe_subtypes(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
subtype_ids = (self.env.ref('test_mail.st_mail_test_simple_external') | self.env.ref('mail.mt_comment')).ids
- with self.assertQueryCount(admin=6, emp=6): # test_mail only: 5 - 5
+ with self.assertQueryCount(__system__=6, emp=6): # test_mail only: 5 - 5
record.message_subscribe(partner_ids=self.user_test.partner_id.ids, subtype_ids=subtype_ids)
- with self.assertQueryCount(admin=2, emp=2): # test_mail only: 1 - 1
+ with self.assertQueryCount(__system__=2, emp=2): # test_mail only: 1 - 1
record.message_subscribe(partner_ids=self.user_test.partner_id.ids, subtype_ids=subtype_ids)
@@ -333,7 +333,6 @@ class TestHeavyMailPerformance(TransactionCase):
})
self.admin = self.env.user
- self.admin.login = 'admin'
# setup mail gateway
self.env['ir.config_parameter'].sudo().set_param('mail.catchall.domain', 'example.com')
@@ -364,7 +363,7 @@ class TestHeavyMailPerformance(TransactionCase):
)
@mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_complex_mail_mail_send(self):
message = self.env['mail.message'].sudo().create({
@@ -382,20 +381,20 @@ class TestHeavyMailPerformance(TransactionCase):
})
mail_ids = mail.ids
- with self.assertQueryCount(admin=13, emp=20): # test_mail only: 13 - 20
+ with self.assertQueryCount(__system__=13, emp=20): # test_mail only: 13 - 20
self.env['mail.mail'].browse(mail_ids).send()
self.assertEqual(mail.body_html, '<p>Test</p>')
self.assertEqual(mail.reply_to, formataddr(('%s %s' % (self.env.user.company_id.name, self.umbrella.name), 'test-alias@example.com')))
@mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_complex_message_post(self):
self.umbrella.message_subscribe(self.user_portal.partner_id.ids)
record = self.umbrella.sudo(self.env.user)
- with self.assertQueryCount(admin=80, emp=103): # com runbot 90 - 113 // test_mail only: 97 - 120
+ with self.assertQueryCount(__system__=80, emp=103): # com runbot 90 - 113 // test_mail only: 97 - 120
record.message_post(
body='<p>Test Post Performances</p>',
message_type='comment',
@@ -405,21 +404,21 @@ class TestHeavyMailPerformance(TransactionCase):
self.assertEqual(record.message_ids[0].needaction_partner_ids, self.partners | self.user_portal.partner_id)
@mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_complex_message_post_template(self):
self.umbrella.message_subscribe(self.user_portal.partner_id.ids)
record = self.umbrella.sudo(self.env.user)
template_id = self.env.ref('test_mail.mail_test_tpl').id
- with self.assertQueryCount(admin=99, emp=134): # com runbot 109 - 144 // test_mail only: 116 - 151
+ with self.assertQueryCount(__system__=99, emp=134): # com runbot 109 - 144 // test_mail only: 116 - 151
record.message_post_with_template(template_id, message_type='comment', composition_mode='comment')
self.assertEqual(record.message_ids[0].body, '<p>Adding stuff on %s</p>' % record.name)
self.assertEqual(record.message_ids[0].needaction_partner_ids, self.partners | self.user_portal.partner_id | self.customer)
@mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_complex_message_subscribe(self):
pids = self.partners.ids
@@ -437,7 +436,7 @@ class TestHeavyMailPerformance(TransactionCase):
self.assertEqual(rec.message_channel_ids, self.env['mail.channel'])
# subscribe new followers with forced given subtypes
- with self.assertQueryCount(admin=9, emp=9): # test_mail only: 8 - 8
+ with self.assertQueryCount(__system__=9, emp=9): # test_mail only: 8 - 8
rec.message_subscribe(
partner_ids=pids[:4],
channel_ids=cids,
@@ -448,7 +447,7 @@ class TestHeavyMailPerformance(TransactionCase):
self.assertEqual(rec.message_channel_ids, self.channel)
# subscribe existing and new followers with force=False, meaning only some new followers will be added
- with self.assertQueryCount(admin=7, emp=7): # test_mail only: 6 - 6
+ with self.assertQueryCount(__system__=7, emp=7): # test_mail only: 6 - 6
rec.message_subscribe(
partner_ids=pids[:6],
channel_ids=cids,
@@ -459,7 +458,7 @@ class TestHeavyMailPerformance(TransactionCase):
self.assertEqual(rec.message_channel_ids, self.channel)
# subscribe existing and new followers with force=True, meaning all will have the same subtypes
- with self.assertQueryCount(admin=8, emp=8): # test_mail only: 7 - 7
+ with self.assertQueryCount(__system__=8, emp=8): # test_mail only: 7 - 7
rec.message_subscribe(
partner_ids=pids,
channel_ids=cids,
@@ -470,7 +469,7 @@ class TestHeavyMailPerformance(TransactionCase):
self.assertEqual(rec.message_channel_ids, self.channel)
@mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_complex_tracking_assignation(self):
""" Assignation performance test on already-created record """
@@ -482,7 +481,7 @@ class TestHeavyMailPerformance(TransactionCase):
})
self.assertEqual(rec.message_partner_ids, self.partners | self.env.user.partner_id)
- with self.assertQueryCount(admin=58, emp=77): # com runbot: 65 - 83 // test_mail only: 66 - 84
+ with self.assertQueryCount(__system__=58, emp=77): # com runbot: 65 - 83 // test_mail only: 66 - 84
rec.write({'user_id': self.user_portal.id})
self.assertEqual(rec.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id)
@@ -497,7 +496,7 @@ class TestHeavyMailPerformance(TransactionCase):
self.assertEqual(rec.message_ids[2].needaction_partner_ids, self.env['res.partner'])
@mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_complex_tracking_subscription_create(self):
""" Creation performance test involving auto subscription, assignation, tracking with subtype and template send. """
@@ -505,7 +504,7 @@ class TestHeavyMailPerformance(TransactionCase):
customer_id = self.customer.id
user_id = self.user_portal.id
- with self.assertQueryCount(admin=155, emp=190): # com runbot: 155 - 190 // test_mail only: 155 - 190
+ with self.assertQueryCount(__system__=155, emp=190): # com runbot: 155 - 190 // test_mail only: 155 - 190
rec = self.env['mail.test.full'].create({
'name': 'Test',
'umbrella_id': umbrella_id,
@@ -522,7 +521,7 @@ class TestHeavyMailPerformance(TransactionCase):
self.assertEqual(rec.message_ids[1].needaction_partner_ids, self.env['res.partner'])
@mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_complex_tracking_subscription_subtype(self):
""" Write performance test involving auto subscription, tracking with subtype """
@@ -534,7 +533,7 @@ class TestHeavyMailPerformance(TransactionCase):
})
self.assertEqual(rec.message_partner_ids, self.user_portal.partner_id | self.env.user.partner_id)
- with self.assertQueryCount(admin=94, emp=111): # com runbot: 104 - 123 // test_mail only: 105 - 124
+ with self.assertQueryCount(__system__=94, emp=111): # com runbot: 104 - 123 // test_mail only: 105 - 124
rec.write({
'name': 'Test2',
'umbrella_id': self.umbrella.id,
@@ -552,7 +551,7 @@ class TestHeavyMailPerformance(TransactionCase):
self.assertEqual(rec.message_ids[2].needaction_partner_ids, self.env['res.partner'])
@mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_complex_tracking_subscription_write(self):
""" Write performance test involving auto subscription, tracking with subtype and template send """
@@ -572,7 +571,7 @@ class TestHeavyMailPerformance(TransactionCase):
})
self.assertEqual(rec.message_partner_ids, self.user_portal.partner_id | self.env.user.partner_id)
- with self.assertQueryCount(admin=100, emp=122): # test_mail only: 111 - 134
+ with self.assertQueryCount(__system__=100, emp=122): # test_mail only: 111 - 134
rec.write({
'name': 'Test2',
'umbrella_id': umbrella_id,
@@ -591,7 +590,7 @@ class TestHeavyMailPerformance(TransactionCase):
self.assertEqual(rec.message_ids[2].needaction_partner_ids, self.env['res.partner'])
@mute_logger('odoo.tests', 'odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
- @users('admin', 'emp')
+ @users('__system__', 'emp')
@warmup
def test_complex_tracking_template(self):
""" Write performance test involving assignation, tracking with template """
@@ -606,7 +605,7 @@ class TestHeavyMailPerformance(TransactionCase):
})
self.assertEqual(rec.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id)
- with self.assertQueryCount(admin=54, emp=76): # test_mail only: 54 - 75
+ with self.assertQueryCount(__system__=54, emp=76): # test_mail only: 54 - 75
rec.write({
'name': 'Test2',
'customer_id': customer_id,