[FIX] tests: check test tags *_install
Making a test post_install using @tagged should always remove the
at_install tag.
The main reason for that is that runbot split config select if an
at_install or post_install tests should be executed is using negation:
`--test-tags -post_install`. The reason for that is that giving a positive tag will
replace the "standard" tag and non standard tag could be executed if
giving `--test-tags at_install` (without negation)
Since runbot tests in parallel builds, one of them using
`--test-tags -post_install` and the other `--test-tags -at_install`,
a test that is both post install and at install wont be executed at all.
Also, a tests with both tags will be executed twice
in a normal flow, usually not intended.
The correct way to make a test post_install is to use
@tagged('post_install', '-at_install')
closes odoo/odoo#118969
X-original-commit: d1db306b212d4abb5b2faab9e56c8e83b85c53b9
Related: odoo/enterprise#39966
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
from odoo.tests import Form, tagged, TransactionCase
|
||||
from odoo.exceptions import MissingError
|
||||
|
||||
@tagged('post_install')
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestEmployeeDeletion(TransactionCase):
|
||||
|
||||
def test_employee_deletion(self):
|
||||
|
||||
@@ -6,7 +6,7 @@ from odoo.tools import mute_logger
|
||||
from odoo.tests import tagged
|
||||
|
||||
|
||||
@tagged('post_install')
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestLiveChatDigest(TestDigestCommon):
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -10,7 +10,7 @@ from odoo.tools import mute_logger, convert_file
|
||||
from odoo.modules.module import get_module_resource
|
||||
|
||||
|
||||
@tagged('post_install')
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestSmsTemplateAccessRights(TransactionCase):
|
||||
|
||||
@classmethod
|
||||
@@ -110,7 +110,7 @@ class TestSmsTemplateAccessRights(TransactionCase):
|
||||
self.assertIn(self.partner.name, body, 'Template Editor should be able to write new Jinja code')
|
||||
|
||||
|
||||
@tagged('post_install')
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestSMSTemplateReset(TransactionCase):
|
||||
|
||||
def _load(self, module, *args):
|
||||
|
||||
@@ -326,7 +326,7 @@ class TestAccess(common.TestSurveyCommon):
|
||||
(answer_own | answer_other | self.answer_0).unlink()
|
||||
|
||||
|
||||
@tagged('post_install')
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestSurveySecurityControllers(common.TestSurveyCommon, HttpCase):
|
||||
def test_survey_start_short(self):
|
||||
# avoid name clash with existing data
|
||||
|
||||
@@ -71,7 +71,6 @@ class TestWebsiteVisitor(TestCrmCommon, WebsiteVisitorTests):
|
||||
self.assertEqual(visitor.email, customer.email_normalized)
|
||||
self.assertEqual(visitor.mobile, lead_2.mobile)
|
||||
|
||||
@tagged('website_visitor')
|
||||
def test_clean_inactive_visitors_crm(self):
|
||||
""" Visitors attached to leads should not be deleted even if not connected recently. """
|
||||
active_visitors = self.env['website.visitor'].create([{
|
||||
@@ -87,7 +86,6 @@ class TestWebsiteVisitor(TestCrmCommon, WebsiteVisitorTests):
|
||||
|
||||
self._test_unlink_old_visitors(self.env['website.visitor'], active_visitors)
|
||||
|
||||
@tagged('website_visitor')
|
||||
def test_link_to_visitor_crm(self):
|
||||
""" Same as parent's 'test_link_to_visitor' except we also test that leads
|
||||
are merged into main visitor. """
|
||||
|
||||
@@ -88,19 +88,19 @@ class TestSetTags(TransactionCase):
|
||||
self.assertEqual(fc.test_tags, {'at_install'})
|
||||
self.assertEqual(fc.test_module, 'base')
|
||||
|
||||
@tagged('-standard', '-base', '-at_install')
|
||||
@tagged('-standard', '-base', '-at_install', 'post_install')
|
||||
class FakeClassB(TransactionCase):
|
||||
pass
|
||||
|
||||
fc = FakeClassB()
|
||||
self.assertEqual(fc.test_tags, set())
|
||||
self.assertEqual(fc.test_tags, {'post_install'})
|
||||
|
||||
@tagged('-standard', '-base', '-at_install', 'fast')
|
||||
@tagged('-standard', '-base', 'fast')
|
||||
class FakeClassC(TransactionCase):
|
||||
pass
|
||||
|
||||
fc = FakeClassC()
|
||||
self.assertEqual(fc.test_tags, {'fast', })
|
||||
self.assertEqual(fc.test_tags, {'fast', 'at_install'})
|
||||
|
||||
def test_parental_advisory(self):
|
||||
"""Explicit test tags on the class should override anything
|
||||
|
||||
@@ -1875,7 +1875,12 @@ def tagged(*tags):
|
||||
"""
|
||||
include = {t for t in tags if not t.startswith('-')}
|
||||
exclude = {t[1:] for t in tags if t.startswith('-')}
|
||||
|
||||
def tags_decorator(obj):
|
||||
obj.test_tags = (getattr(obj, 'test_tags', set()) | include) - exclude
|
||||
at_install = 'at_install' in obj.test_tags
|
||||
post_install = 'post_install' in obj.test_tags
|
||||
if not (at_install ^ post_install):
|
||||
_logger.warning('A tests should be either at_install or post_install, which is not the case of %r', obj)
|
||||
return obj
|
||||
return tags_decorator
|
||||
|
||||
Reference in New Issue
Block a user