[ADD] test_base_automation: Move tests and related models
Purpose ======= This module contains tests related to base automation. It makes no sense as they have no business value. Specification ============= Move all the tests to a separate module as it contains models used only to perform tests independently to functional aspects of other models.
This commit is contained in:
@@ -2,4 +2,3 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
from .tests import test_models
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_base_automation,base.automation,model_base_automation,,1,0,0,0
|
||||
access_base_automation_config,base.automation config,model_base_automation,base.group_system,1,1,1,1
|
||||
access_base_automation_lead_test,access_base_automation_lead_test,model_base_automation_lead_test,base.group_system,1,1,1,1
|
||||
access_base_automation_line_test,access_base_automation_line_test,model_base_automation_line_test,base.group_system,1,1,1,1
|
||||
|
@@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import test_models
|
||||
from . import test_base_automation
|
||||
from . import models
|
||||
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
{
|
||||
'name': 'Test - Base Automation',
|
||||
'version': '1.0',
|
||||
'category': 'Hidden',
|
||||
'sequence': 9877,
|
||||
'summary': 'Base Automation Tests: Ensure Flow Robustness',
|
||||
'description': """This module contains tests related to base automation. Those are
|
||||
contained in a separate module as it contains models used only to perform
|
||||
tests independently to functional aspects of other models.""",
|
||||
'depends': ['base_automation'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'installable': True,
|
||||
'application': False,
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import test_base_automation
|
||||
+1
-2
@@ -4,7 +4,7 @@
|
||||
from dateutil import relativedelta
|
||||
from odoo import fields, models, api
|
||||
|
||||
# YTI TODO: Move this brol to a new test_base_automation module
|
||||
|
||||
class LeadTest(models.Model):
|
||||
_name = "base.automation.lead.test"
|
||||
_description = "Automated Rule Test"
|
||||
@@ -42,7 +42,6 @@ class LeadTest(models.Model):
|
||||
return result
|
||||
|
||||
|
||||
|
||||
class LineTest(models.Model):
|
||||
_name = "base.automation.line.test"
|
||||
_description = "Automated Rule Line Test"
|
||||
@@ -0,0 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_base_automation_lead_test,access_base_automation_lead_test,model_base_automation_lead_test,base.group_system,1,1,1,1
|
||||
access_base_automation_line_test,access_base_automation_line_test,model_base_automation_line_test,base.group_system,1,1,1,1
|
||||
|
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import test_flow
|
||||
+13
-12
@@ -1,5 +1,6 @@
|
||||
# # -*- coding: utf-8 -*-
|
||||
# # Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from odoo.addons.base.tests.common import TransactionCaseWithUserDemo
|
||||
@@ -16,7 +17,7 @@ class BaseAutomationTest(TransactionCaseWithUserDemo):
|
||||
|
||||
self.test_mail_template_automation = self.env['mail.template'].create({
|
||||
'name': 'Template Automation',
|
||||
'model_id': self.env.ref('base_automation.model_base_automation_lead_test').id,
|
||||
'model_id': self.env.ref('test_base_automation.model_base_automation_lead_test').id,
|
||||
'body_html': """<div>Email automation</div>""",
|
||||
})
|
||||
|
||||
@@ -24,7 +25,7 @@ class BaseAutomationTest(TransactionCaseWithUserDemo):
|
||||
self.env['base.automation'].create([
|
||||
{
|
||||
'name': 'Base Automation: test rule on create',
|
||||
'model_id': self.env.ref('base_automation.model_base_automation_lead_test').id,
|
||||
'model_id': self.env.ref('test_base_automation.model_base_automation_lead_test').id,
|
||||
'state': 'code',
|
||||
'code': "records.write({'user_id': %s})" % (self.user_demo.id),
|
||||
'trigger': 'on_create',
|
||||
@@ -32,7 +33,7 @@ class BaseAutomationTest(TransactionCaseWithUserDemo):
|
||||
'filter_domain': "[('state', '=', 'draft')]",
|
||||
}, {
|
||||
'name': 'Base Automation: test rule on write',
|
||||
'model_id': self.env.ref('base_automation.model_base_automation_lead_test').id,
|
||||
'model_id': self.env.ref('test_base_automation.model_base_automation_lead_test').id,
|
||||
'state': 'code',
|
||||
'code': "records.write({'user_id': %s})" % (self.user_demo.id),
|
||||
'trigger': 'on_write',
|
||||
@@ -41,7 +42,7 @@ class BaseAutomationTest(TransactionCaseWithUserDemo):
|
||||
'filter_pre_domain': "[('state', '=', 'open')]",
|
||||
}, {
|
||||
'name': 'Base Automation: test rule on recompute',
|
||||
'model_id': self.env.ref('base_automation.model_base_automation_lead_test').id,
|
||||
'model_id': self.env.ref('test_base_automation.model_base_automation_lead_test').id,
|
||||
'state': 'code',
|
||||
'code': "records.write({'user_id': %s})" % (self.user_demo.id),
|
||||
'trigger': 'on_write',
|
||||
@@ -49,7 +50,7 @@ class BaseAutomationTest(TransactionCaseWithUserDemo):
|
||||
'filter_domain': "[('employee', '=', True)]",
|
||||
}, {
|
||||
'name': 'Base Automation: test recursive rule',
|
||||
'model_id': self.env.ref('base_automation.model_base_automation_lead_test').id,
|
||||
'model_id': self.env.ref('test_base_automation.model_base_automation_lead_test').id,
|
||||
'state': 'code',
|
||||
'code': """
|
||||
record = model.browse(env.context['active_id'])
|
||||
@@ -59,14 +60,14 @@ if 'partner_id' in env.context['old_values'][record.id]:
|
||||
'active': True,
|
||||
}, {
|
||||
'name': 'Base Automation: test rule on secondary model',
|
||||
'model_id': self.env.ref('base_automation.model_base_automation_line_test').id,
|
||||
'model_id': self.env.ref('test_base_automation.model_base_automation_line_test').id,
|
||||
'state': 'code',
|
||||
'code': "records.write({'user_id': %s})" % (self.user_demo.id),
|
||||
'trigger': 'on_create',
|
||||
'active': True,
|
||||
}, {
|
||||
'name': 'Base Automation: test rule on write check context',
|
||||
'model_id': self.env.ref('base_automation.model_base_automation_lead_test').id,
|
||||
'model_id': self.env.ref('test_base_automation.model_base_automation_lead_test').id,
|
||||
'state': 'code',
|
||||
'code': """
|
||||
record = model.browse(env.context['active_id'])
|
||||
@@ -76,8 +77,8 @@ if 'user_id' in env.context['old_values'][record.id]:
|
||||
'active': True,
|
||||
}, {
|
||||
'name': 'Base Automation: test rule with trigger',
|
||||
'model_id': self.env.ref('base_automation.model_base_automation_lead_test').id,
|
||||
'trigger_field_ids': [(4, self.env.ref('base_automation.field_base_automation_lead_test__state').id)],
|
||||
'model_id': self.env.ref('test_base_automation.model_base_automation_lead_test').id,
|
||||
'trigger_field_ids': [(4, self.env.ref('test_base_automation.field_base_automation_lead_test__state').id)],
|
||||
'state': 'code',
|
||||
'code': """
|
||||
record = model.browse(env.context['active_id'])
|
||||
@@ -86,9 +87,9 @@ record['name'] = record.name + 'X'""",
|
||||
'active': True,
|
||||
}, {
|
||||
'name': 'Base Automation: test send an email',
|
||||
'model_id': self.env.ref('base_automation.model_base_automation_lead_test').id,
|
||||
'model_id': self.env.ref('test_base_automation.model_base_automation_lead_test').id,
|
||||
'template_id': self.test_mail_template_automation.id,
|
||||
'trigger_field_ids': [(4, self.env.ref('base_automation.field_base_automation_lead_test__deadline').id)],
|
||||
'trigger_field_ids': [(4, self.env.ref('test_base_automation.field_base_automation_lead_test__deadline').id)],
|
||||
'state': 'email',
|
||||
'code': """
|
||||
record = model.browse(env.context['active_id'])
|
||||
@@ -283,7 +284,7 @@ record['name'] = record.name + 'X'""",
|
||||
|
||||
# change the rule to trigger on partner_id
|
||||
rule = self.env['base.automation'].search([('name', '=', 'Base Automation: test rule with trigger')])
|
||||
rule.write({'trigger_field_ids': [(6, 0, [self.env.ref('base_automation.field_base_automation_lead_test__partner_id').id])]})
|
||||
rule.write({'trigger_field_ids': [(6, 0, [self.env.ref('test_base_automation.field_base_automation_lead_test__partner_id').id])]})
|
||||
|
||||
partner2 = self.env['res.partner'].create({'name': 'A new partner'})
|
||||
lead.name = 'X'
|
||||
Reference in New Issue
Block a user