diff --git a/addons/base_automation/__init__.py b/addons/base_automation/__init__.py index 56990e4d8ee57f3ddb4d4ed98cfdb65feb86f9f3..dc5e6b693d19dcacd224b7ab27b26f75e66cb7b2 100644 --- a/addons/base_automation/__init__.py +++ b/addons/base_automation/__init__.py @@ -2,4 +2,3 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import models -from .tests import test_models diff --git a/addons/base_automation/security/ir.model.access.csv b/addons/base_automation/security/ir.model.access.csv index 2dc7103a91baa4fcfd90919e02ea3d9af1493f3b..6b1d50350d012a81d6fb28863370188231269a17 100644 --- a/addons/base_automation/security/ir.model.access.csv +++ b/addons/base_automation/security/ir.model.access.csv @@ -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 \ No newline at end of file diff --git a/addons/base_automation/tests/__init__.py b/addons/test_base_automation/__init__.py similarity index 62% rename from addons/base_automation/tests/__init__.py rename to addons/test_base_automation/__init__.py index b0ebb370682dcfeaedd0c7dfb0afac175dd576af..dc5e6b693d19dcacd224b7ab27b26f75e66cb7b2 100644 --- a/addons/base_automation/tests/__init__.py +++ b/addons/test_base_automation/__init__.py @@ -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 diff --git a/addons/test_base_automation/__manifest__.py b/addons/test_base_automation/__manifest__.py new file mode 100644 index 0000000000000000000000000000000000000000..4cbc1d7f0ab8705508c3de829f14a36355c2da43 --- /dev/null +++ b/addons/test_base_automation/__manifest__.py @@ -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, +} diff --git a/addons/test_base_automation/models/__init__.py b/addons/test_base_automation/models/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..5bf71275255c5947e96fd728af262e5c81747091 --- /dev/null +++ b/addons/test_base_automation/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import test_base_automation \ No newline at end of file diff --git a/addons/base_automation/tests/test_models.py b/addons/test_base_automation/models/test_base_automation.py similarity index 97% rename from addons/base_automation/tests/test_models.py rename to addons/test_base_automation/models/test_base_automation.py index c3b4ca4000fc71592456a8d1ff0f0efbee5f66a6..b2109f3185de26b38ac2e2e7c0077976e732e412 100644 --- a/addons/base_automation/tests/test_models.py +++ b/addons/test_base_automation/models/test_base_automation.py @@ -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" diff --git a/addons/test_base_automation/security/ir.model.access.csv b/addons/test_base_automation/security/ir.model.access.csv new file mode 100644 index 0000000000000000000000000000000000000000..cc380da05adbe9346b9871a1ecdc66a68c777d6b --- /dev/null +++ b/addons/test_base_automation/security/ir.model.access.csv @@ -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 diff --git a/addons/test_base_automation/tests/__init__.py b/addons/test_base_automation/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..b96c2ec87d5106c75b92f61eaa8e128f902f54f1 --- /dev/null +++ b/addons/test_base_automation/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import test_flow diff --git a/addons/base_automation/tests/test_base_automation.py b/addons/test_base_automation/tests/test_flow.py similarity index 91% rename from addons/base_automation/tests/test_base_automation.py rename to addons/test_base_automation/tests/test_flow.py index c768bc7a141ad3e4326bbe8ad9b499db83bfd965..657add84892b6154c06aab4aea0d0f798858e813 100644 --- a/addons/base_automation/tests/test_base_automation.py +++ b/addons/test_base_automation/tests/test_flow.py @@ -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'