summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2019-04-05 13:57:09 +0000
committerSimon Lejeune <sle@openerp.com>2019-04-15 07:32:32 +0000
commit4ad81157e76bb779cfcb6221966416627e9243fb (patch)
treec193d89775f0a6f5e44c564e00be454d24f1aac5
parent81afb100839348b55c45a0738696e47138a2c030 (diff)
[REF] mrp_subcontracting: speedup tests
Before on runbot odoo.addons.mrp_subcontracting.tests.test_subcontracting tested in 11.40s, 14213 queries After on runbot odoo.addons.mrp_subcontracting.tests.test_subcontracting tested in 7.95s, 9863 queries
-rw-r--r--addons/mrp_subcontracting/tests/test_subcontracting.py49
1 files changed, 25 insertions, 24 deletions
diff --git a/addons/mrp_subcontracting/tests/test_subcontracting.py b/addons/mrp_subcontracting/tests/test_subcontracting.py
index 856f9849b6f..16601931aff 100644
--- a/addons/mrp_subcontracting/tests/test_subcontracting.py
+++ b/addons/mrp_subcontracting/tests/test_subcontracting.py
@@ -2,7 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests import Form
-from odoo.tests.common import TransactionCase
+from odoo.tests.common import SavepointCase, TransactionCase
from odoo.tests import tagged
@@ -114,56 +114,57 @@ class TestSubcontractingBasic(TransactionCase):
self.assertTrue(company2.subcontracting_location_id)
-class TestSubcontractingFlows(TransactionCase):
- def setUp(self):
- super(TestSubcontractingFlows, self).setUp()
+class TestSubcontractingFlows(SavepointCase):
+ @classmethod
+ def setUpClass(cls):
+ super(TestSubcontractingFlows, cls).setUpClass()
# 1: Create a subcontracting partner
- main_partner = self.env['res.partner'].create({'name': 'main_partner'})
- self.subcontractor_partner1 = self.env['res.partner'].create({
+ main_partner = cls.env['res.partner'].create({'name': 'main_partner'})
+ cls.subcontractor_partner1 = cls.env['res.partner'].create({
'name': 'subcontractor_partner',
'type': 'subcontractor',
'parent_id': main_partner.id,
})
# 2. Create a BOM of subcontracting type
- self.comp1 = self.env['product.product'].create({
+ cls.comp1 = cls.env['product.product'].create({
'name': 'Component1',
'type': 'product',
- 'categ_id': self.env.ref('product.product_category_all').id,
+ 'categ_id': cls.env.ref('product.product_category_all').id,
})
- self.comp2 = self.env['product.product'].create({
+ cls.comp2 = cls.env['product.product'].create({
'name': 'Component2',
'type': 'product',
- 'categ_id': self.env.ref('product.product_category_all').id,
+ 'categ_id': cls.env.ref('product.product_category_all').id,
})
- self.finished = self.env['product.product'].create({
+ cls.finished = cls.env['product.product'].create({
'name': 'finished',
'type': 'product',
- 'categ_id': self.env.ref('product.product_category_all').id,
+ 'categ_id': cls.env.ref('product.product_category_all').id,
})
- bom_form = Form(self.env['mrp.bom'])
+ bom_form = Form(cls.env['mrp.bom'])
bom_form.type = 'subcontract'
- bom_form.product_tmpl_id = self.finished.product_tmpl_id
+ bom_form.product_tmpl_id = cls.finished.product_tmpl_id
with bom_form.bom_line_ids.new() as bom_line:
- bom_line.product_id = self.comp1
+ bom_line.product_id = cls.comp1
bom_line.product_qty = 1
with bom_form.bom_line_ids.new() as bom_line:
- bom_line.product_id = self.comp2
+ bom_line.product_id = cls.comp2
bom_line.product_qty = 1
- self.bom = bom_form.save()
+ cls.bom = bom_form.save()
- # Create a BoM for self.comp2
- self.comp2comp = self.env['product.product'].create({
+ # Create a BoM for cls.comp2
+ cls.comp2comp = cls.env['product.product'].create({
'name': 'component for Component2',
'type': 'product',
- 'categ_id': self.env.ref('product.product_category_all').id,
+ 'categ_id': cls.env.ref('product.product_category_all').id,
})
- bom_form = Form(self.env['mrp.bom'])
- bom_form.product_tmpl_id = self.comp2.product_tmpl_id
+ bom_form = Form(cls.env['mrp.bom'])
+ bom_form.product_tmpl_id = cls.comp2.product_tmpl_id
with bom_form.bom_line_ids.new() as bom_line:
- bom_line.product_id = self.comp2comp
+ bom_line.product_id = cls.comp2comp
bom_line.product_qty = 1
- self.comp2_bom = bom_form.save()
+ cls.comp2_bom = bom_form.save()
def test_flow_1(self):
""" Don't tick any route on the components and trigger the creation of the subcontracting