Revert "[IMP] test_mail(_full): run tests at post_install"

This reverts commit 976e560a87.

Even if it didn't looked like a bad idea, this need some more thinking.
This new version of query count creates random failure of runbot builds.

closes odoo/odoo#43820

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Xavier-Do
2020-01-23 09:19:12 +00:00
parent 9b1145001a
commit 8970127c03
26 changed files with 47 additions and 90 deletions
-2
View File
@@ -2,11 +2,9 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged('post_install', '-at_install')
class TestChatterTweaks(TestMailCommon, TestRecipients):
@classmethod
-2
View File
@@ -2,11 +2,9 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged('post_install', '-at_install')
class TestInvite(TestMailCommon):
@mute_logger('odoo.addons.mail.models.mail_mail')
@@ -3,10 +3,8 @@
from odoo.addons.base.tests.test_ir_actions import TestServerActionsBase
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestServerActionsEmail(TestMailCommon, TestServerActionsBase):
def test_action_email(self):
+3 -3
View File
@@ -24,7 +24,7 @@ class TestActivityCommon(TestMailCommon):
cls._reset_mail_context(cls.test_record)
@tests.tagged('mail_activity', 'post_install', '-at_install')
@tests.tagged('mail_activity')
class TestActivityRights(TestActivityCommon):
@mute_logger('odoo.addons.mail.models.mail_mail')
@@ -85,7 +85,7 @@ class TestActivityRights(TestActivityCommon):
user_id=self.user_admin.id)
@tests.tagged('mail_activity', 'post_install', '-at_install')
@tests.tagged('mail_activity')
class TestActivityFlow(TestActivityCommon):
def test_activity_flow_employee(self):
@@ -149,7 +149,7 @@ class TestActivityFlow(TestActivityCommon):
self.assertEqual(activity.user_id, self.user_employee)
@tests.tagged('mail_activity', 'post_install', '-at_install')
@tests.tagged('mail_activity')
class TestActivityMixin(TestActivityCommon):
@mute_logger('odoo.addons.mail.models.mail_mail')
+1 -3
View File
@@ -8,7 +8,6 @@ from odoo.exceptions import AccessError, except_orm, ValidationError, UserError
from odoo.tools import mute_logger, formataddr
@tagged('post_install', '-at_install')
class TestChannelAccessRights(TestMailCommon):
@classmethod
@@ -112,7 +111,6 @@ class TestChannelAccessRights(TestMailCommon):
trigger_read = partner.with_user(self.user_portal).name
@tagged('post_install', '-at_install')
class TestChannelFeatures(TestMailCommon):
@classmethod
@@ -210,7 +208,7 @@ class TestChannelFeatures(TestMailCommon):
self.assertEqual(infos[0]['direct_partner'][0]['out_of_office_message'], 'Out')
@tagged('moderation', 'post_install', '-at_install')
@tagged('moderation')
class TestChannelModeration(TestMailCommon):
@classmethod
@@ -4,11 +4,9 @@
from psycopg2 import IntegrityError
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.tests import tagged
from odoo.tools.misc import mute_logger
@tagged('post_install', '-at_install')
class BaseFollowersTest(TestMailCommon):
@classmethod
@@ -119,7 +117,6 @@ class BaseFollowersTest(TestMailCommon):
})
@tagged('post_install', '-at_install')
class AdvancedFollowersTest(TestMailCommon):
@classmethod
def setUpClass(cls):
+3 -4
View File
@@ -16,7 +16,7 @@ from odoo.tests import tagged
from odoo.tools import email_split_and_format, formataddr, mute_logger
@tagged('mail_gateway', 'post_install', '-at_install')
@tagged('mail_gateway')
class TestEmailParsing(TestMailCommon):
def test_message_parse_body(self):
@@ -70,7 +70,7 @@ class TestEmailParsing(TestMailCommon):
self.env['mail.thread'].message_parse(self.from_string(test_mail_data.MAIL_XHTML))
@tagged('mail_gateway', 'post_install', '-at_install')
@tagged('mail_gateway')
class TestMailAlias(TestMailCommon):
def test_alias_setup(self):
@@ -78,7 +78,7 @@ class TestMailAlias(TestMailCommon):
self.assertEqual(alias.alias_name, 'b4r+_-_r3wl-', 'Disallowed chars should be replaced by hyphens')
@tagged('mail_gateway', 'post_install', '-at_install')
@tagged('mail_gateway')
class TestMailgateway(TestMailCommon):
@classmethod
@@ -737,7 +737,6 @@ class TestMailgateway(TestMailCommon):
self.assertEqual(record._name, 'mail.test.gateway')
@tagged('post_install', '-at_install')
class TestMailThreadCC(TestMailCommon):
@classmethod
+1 -3
View File
@@ -6,11 +6,10 @@ import psycopg2
from odoo import api
from odoo.addons.base.models.ir_mail_server import MailDeliveryException
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.tests import common, tagged
from odoo.tests import common
from odoo.tools import mute_logger
@tagged('post_install', '-at_install')
class TestMailMail(TestMailCommon):
@mute_logger('odoo.addons.mail.models.mail_mail')
@@ -37,7 +36,6 @@ class TestMailMail(TestMailCommon):
self.assertRaises(MailDeliveryException, lambda: mail.send(raise_exception=True))
@tagged('post_install', '-at_install')
class TestMailMailRace(common.TransactionCase):
@mute_logger('odoo.addons.mail.models.mail_mail')
+1 -2
View File
@@ -6,11 +6,10 @@ import base64
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.exceptions import AccessError, except_orm
from odoo.tests import tagged
from odoo.tools import mute_logger, formataddr
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestMessageValues(TestMailCommon):
@classmethod
@@ -4,11 +4,9 @@
import base64
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged('post_install', '-at_install')
class TestMailTemplate(TestMailCommon, TestRecipients):
@classmethod
@@ -7,11 +7,9 @@ from unittest.mock import patch
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.addons.test_mail.models.test_mail_models import MailTestSimple
from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged('post_install', '-at_install')
class TestComposer(TestMailCommon, TestRecipients):
@classmethod
@@ -155,7 +153,6 @@ class TestComposer(TestMailCommon, TestRecipients):
self.assertEqual(self.test_record.message_ids[0].author_id, portal_user.partner_id)
@tagged('post_install', '-at_install')
class TestComposerWTpl(TestMailCommon, TestRecipients):
@classmethod
@@ -7,7 +7,7 @@ from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged('mail_wizards', 'post_install', '-at_install')
@tagged('mail_wizards')
class TestMailResend(TestMailCommon):
@classmethod
@@ -9,11 +9,9 @@ from odoo.addons.test_mail.data.test_mail_data import MAIL_TEMPLATE_PLAINTEXT
from odoo.addons.test_mail.models.test_mail_models import MailTestSimple
from odoo.addons.test_mail.tests.common import TestMailCommon, TestRecipients
from odoo.exceptions import AccessError
from odoo.tests import tagged
from odoo.tools import mute_logger, formataddr
@tagged('post_install', '-at_install')
class TestMessagePost(TestMailCommon, TestRecipients):
@classmethod
@@ -4,10 +4,8 @@
from unittest.mock import patch
from odoo.addons.test_mail.tests.common import TestMailCommon
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestTracking(TestMailCommon):
def setUp(self):
+1 -1
View File
@@ -8,7 +8,7 @@ from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged("odoobot", 'post_install', '-at_install')
@tagged("odoobot")
class TestOdoobot(TestMailCommon, TestRecipients):
@classmethod
+32 -31
View File
@@ -3,12 +3,12 @@
import base64
from odoo.addons.base.tests.common import TransactionCaseWithUserDemo
from odoo.tests.common import users, warmup
from odoo.tests.common import TransactionCase, users, warmup
from odoo.tests import tagged
from odoo.tools import mute_logger, formataddr
@tagged('mail_performance', 'post_install', '-at_install')
@tagged('mail_performance')
class BaseMailPerformance(TransactionCaseWithUserDemo):
def setUp(self):
@@ -32,7 +32,7 @@ class BaseMailPerformance(TransactionCaseWithUserDemo):
self.patch(self.env.registry, 'ready', True)
@tagged('mail_performance', 'post_install', '-at_install')
@tagged('mail_performance')
class TestMailPerformance(BaseMailPerformance):
def setUp(self):
@@ -167,7 +167,7 @@ class TestMailPerformance(BaseMailPerformance):
})
@tagged('mail_performance', 'post_install', '-at_install')
@tagged('mail_performance')
class TestMailAPIPerformance(BaseMailPerformance):
def setUp(self):
@@ -226,11 +226,11 @@ class TestMailAPIPerformance(BaseMailPerformance):
'res_id': record.id,
'activity_type_id': self.env.ref('mail.mail_activity_data_todo').id,
})
# 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_feedback
activity.activity_type_id.category
#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_feedback
category = activity.activity_type_id.category
with self.assertQueryCount(__system__=19 + 1, emp=22 + 1):
with self.assertQueryCount(__system__=19, emp=22):
activity.action_feedback(feedback='Zizisse Done !')
@users('__system__', 'emp')
@@ -241,13 +241,13 @@ class TestMailAPIPerformance(BaseMailPerformance):
with self.assertQueryCount(__system__=8, emp=8):
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
activity.activity_type_id.category
#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
category = activity.activity_type_id.category
record.write({'name': 'Dupe write'})
with self.assertQueryCount(__system__=20 + 1, emp=22 + 1):
with self.assertQueryCount(__system__=20, emp=22):
record.action_close('Dupe feedback')
self.assertEqual(record.activity_ids, self.env['mail.activity'])
@@ -268,7 +268,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'partner_ids': [(4, customer_id)],
})
with self.assertQueryCount(__system__=38 + 1, emp=44 + 1):
with self.assertQueryCount(__system__=38, emp=44):
composer.send_mail()
@users('__system__', 'emp')
@@ -278,7 +278,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
test_record = self.env['mail.test.full'].browse(self.test_record_full.id)
test_template = self.env['mail.template'].browse(self.test_template_full.id)
# TODO XDO/TDE FIXME non deterministic between 25 and 28 queries
with self.assertQueryCount(__system__=21 + 12, emp=21 + 12):
with self.assertQueryCount(__system__=28, emp=28):
composer = self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
'default_model': test_record._name,
@@ -287,7 +287,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
}).create({})
composer.onchange_template_id_wrapper()
with self.assertQueryCount(__system__=46 + 1, emp=51 + 1):
with self.assertQueryCount(__system__=46, emp=51):
composer.send_mail()
# remove created partner to ensure tests are the same each run
@@ -299,7 +299,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
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(__system__=40 + 2, emp=41 + 2):
with self.assertQueryCount(__system__=40, emp=41):
record.write({
'user_id': self.user_test.id,
})
@@ -308,7 +308,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
@warmup
def test_message_assignation_inbox(self):
record = self.env['mail.test.track'].create({'name': 'Test'})
with self.assertQueryCount(__system__=27 + 1, emp=29 + 1):
with self.assertQueryCount(__system__=27, emp=29):
record.write({
'user_id': self.user_test.id,
})
@@ -352,7 +352,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_message_post_one_email_notification(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
with self.assertQueryCount(__system__=33 + 1, emp=34 + 1):
with self.assertQueryCount(__system__=33, emp=34):
record.message_post(
body='<p>Test Post Performances with an email ping</p>',
partner_ids=self.customer.ids,
@@ -397,7 +397,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
record.message_subscribe(partner_ids=self.user_test.partner_id.ids, subtype_ids=subtype_ids)
@tagged('mail_performance', 'post_install', '-at_install')
@tagged('mail_performance')
class TestMailComplexPerformance(BaseMailPerformance):
def setUp(self):
@@ -472,7 +472,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
self.umbrella.message_subscribe(self.user_portal.partner_id.ids)
record = self.umbrella.with_user(self.env.user)
with self.assertQueryCount(__system__=73 + 1, emp=74 + 1):
with self.assertQueryCount(__system__=73, emp=74):
record.message_post(
body='<p>Test Post Performances</p>',
message_type='comment',
@@ -489,7 +489,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
record = self.umbrella.with_user(self.env.user)
template_id = self.env.ref('test_mail.mail_test_tpl').id
with self.assertQueryCount(__system__=84 + 3, emp=85 + 3):
with self.assertQueryCount(__system__=84, emp=85):
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)
@@ -560,7 +560,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
})
rec1 = rec.with_context(active_test=False) # to see inactive records
self.assertEqual(rec1.message_partner_ids, self.partners | self.env.user.partner_id)
with self.assertQueryCount(__system__=39 + 2, emp=40 + 2):
with self.assertQueryCount(__system__=39, emp=40):
rec.write({'user_id': self.user_portal.id})
self.assertEqual(rec1.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id)
# write tracking message
@@ -580,7 +580,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
customer_id = self.customer.id
user_id = self.user_portal.id
with self.assertQueryCount(__system__=123 + 3, emp=124 + 3):
with self.assertQueryCount(__system__=123, emp=124):
rec = self.env['mail.test.full'].create({
'name': 'Test',
'umbrella_id': umbrella_id,
@@ -609,11 +609,11 @@ class TestMailComplexPerformance(BaseMailPerformance):
rec1 = rec.with_context(active_test=False) # to see inactive records
self.assertEqual(rec1.message_partner_ids, self.user_portal.partner_id | self.env.user.partner_id)
self.assertEqual(len(rec1.message_ids), 1)
with self.assertQueryCount(__system__=87 + 1, emp=88 + 1):
with self.assertQueryCount(__system__=87, emp=88):
rec.write({
'name': 'Test2',
'umbrella_id': self.umbrella.id,
})
})
self.assertEqual(rec1.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id)
# write tracking message
@@ -646,12 +646,13 @@ class TestMailComplexPerformance(BaseMailPerformance):
rec1 = rec.with_context(active_test=False) # to see inactive records
self.assertEqual(rec1.message_partner_ids, self.user_portal.partner_id | self.env.user.partner_id)
with self.assertQueryCount(__system__=95 + 1, emp=96 + 1):
with self.assertQueryCount(__system__=95, emp=96):
rec.write({
'name': 'Test2',
'umbrella_id': umbrella_id,
'customer_id': customer_id,
})
})
self.assertEqual(rec1.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id)
# write tracking message
@@ -679,7 +680,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
rec1 = rec.with_context(active_test=False) # to see inactive records
self.assertEqual(rec1.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id)
with self.assertQueryCount(__system__=34 + 1, emp=35 + 1):
with self.assertQueryCount(__system__=34, emp=35):
rec.write({
'name': 'Test2',
'customer_id': customer_id,
@@ -698,7 +699,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
self.assertEqual(len(rec1.message_ids), 3)
@tagged('mail_performance', 'post_install', '-at_install')
@tagged('mail_performance')
class TestMailHeavyPerformancePost(BaseMailPerformance):
def setUp(self):
@@ -816,7 +817,7 @@ class TestMailHeavyPerformancePost(BaseMailPerformance):
]
self.attachements = self.env['ir.attachment'].with_user(self.env.user).create(self.vals)
attachement_ids = self.attachements.ids
with self.assertQueryCount(emp=92 + 17):
with self.assertQueryCount(emp=92):
self.cr.sql_log = self.warm and self.cr.sql_log_count
record.with_context({}).message_post(
body='<p>Test body <img src="cid:cid1"> <img src="cid:cid2"></p>',
@@ -839,7 +840,7 @@ class TestMailHeavyPerformancePost(BaseMailPerformance):
# self.assertEqual(record.message_ids[0].notified_partner_ids, [])
@tagged('mail_performance', 'post_install', '-at_install')
@tagged('mail_performance')
class TestTrackingPerformance(BaseMailPerformance):
@users('__system__', 'demo')
@@ -1,10 +1,7 @@
# -*- coding: utf-8 -*-
from odoo.tests import tagged
from odoo.tests.common import TransactionCase
@tagged('post_install', '-at_install')
class TestUpdateNotification(TransactionCase):
def test_user_count(self):
ping_msg = self.env['publisher_warranty.contract'].with_context(active_test=False)._get_message()
+1 -1
View File
@@ -7,7 +7,7 @@ from odoo.addons.test_mail_full.tests import common as test_mail_full_common
from odoo.tests import tagged
@tagged('mass_mailing', 'post_install', '-at_install')
@tagged('mass_mailing')
class TestMassSMS(test_mail_full_common.TestSMSCommon):
@classmethod
@@ -2,10 +2,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail_full.tests import common as test_mail_full_common
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestPhoneBlacklist(test_mail_full_common.TestSMSCommon, test_mail_full_common.TestRecipients):
""" TODO """
@@ -2,10 +2,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail_full.tests import common as test_mail_full_common
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestSMSComposerComment(test_mail_full_common.TestSMSCommon, test_mail_full_common.TestRecipients):
""" TODO LIST
@@ -134,7 +132,6 @@ class TestSMSComposerComment(test_mail_full_common.TestSMSCommon, test_mail_full
self.assertSMSSent(self.random_numbers_san, self._test_body)
@tagged('post_install', '-at_install')
class TestSMSComposerBatch(test_mail_full_common.TestSMSCommon):
@classmethod
def setUpClass(cls):
@@ -211,7 +208,6 @@ class TestSMSComposerBatch(test_mail_full_common.TestSMSCommon):
self.assertSMSNotification([{'partner': r.customer_id} for r in self.records], 'Zizisse an SMS.', messages)
@tagged('post_install', '-at_install')
class TestSMSComposerMass(test_mail_full_common.TestSMSCommon):
@classmethod
@@ -2,10 +2,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail_full.tests import common as test_mail_full_common
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestSMSWizards(test_mail_full_common.TestSMSCommon, test_mail_full_common.TestRecipients):
@classmethod
@@ -8,7 +8,7 @@ from odoo.tests import tagged
from odoo.tools import mute_logger
@tagged('mail_performance', 'post_install', '-at_install')
@tagged('mail_performance')
class TestSMSPerformance(BaseMailPerformance, sms_common.MockSMS):
def setUp(self):
@@ -89,7 +89,7 @@ class TestSMSPerformance(BaseMailPerformance, sms_common.MockSMS):
self.assertSMSNotification([{'partner': self.customer}], 'Performance Test', messages)
@tagged('mail_performance', 'post_install', '-at_install')
@tagged('mail_performance')
class TestSMSMassPerformance(BaseMailPerformance, sms_common.MockSMS):
def setUp(self):
@@ -2,10 +2,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail_full.tests import common as test_mail_full_common
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestSMSPost(test_mail_full_common.TestSMSCommon, test_mail_full_common.TestRecipients):
""" TODO
@@ -221,7 +219,6 @@ class TestSMSPost(test_mail_full_common.TestSMSCommon, test_mail_full_common.Tes
self.assertSMSNotification([{'partner': self.partner_1, 'number': self.test_numbers_san[1]}], 'Dear %s this is an SMS.' % self.test_record.display_name, messages)
@tagged('post_install', '-at_install')
class TestSMSPostException(test_mail_full_common.TestSMSCommon, test_mail_full_common.TestRecipients):
@classmethod
@@ -342,7 +339,6 @@ class TestSMSPostException(test_mail_full_common.TestSMSCommon, test_mail_full_c
], self._test_body, messages)
@tagged('post_install', '-at_install')
class TestSMSApi(test_mail_full_common.TestSMSCommon):
@classmethod
@@ -2,10 +2,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail_full.tests import common as test_mail_full_common
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestServerAction(test_mail_full_common.TestSMSCommon, test_mail_full_common.TestRecipients):
@classmethod
+1 -2
View File
@@ -9,7 +9,7 @@ from unittest.mock import DEFAULT
from odoo import exceptions
from odoo.addons.sms.models.sms_sms import SmsSms as SmsSms
from odoo.addons.test_mail_full.tests import common as test_mail_full_common
from odoo.tests import common, tagged
from odoo.tests import common
class LinkTrackerMock(common.BaseCase):
@@ -47,7 +47,6 @@ class LinkTrackerMock(common.BaseCase):
self.assertEqual(redirect_params, url_params)
@tagged('post_install', '-at_install')
class TestSMSPost(test_mail_full_common.TestSMSCommon, LinkTrackerMock):
@classmethod
@@ -2,10 +2,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.test_mail_full.tests import common as test_mail_full_common
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestSmsTemplate(test_mail_full_common.TestSMSCommon, test_mail_full_common.TestRecipients):
@classmethod