From 7022354aa112417e9d33f098cd2b819ec2693c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Mon, 25 May 2015 18:29:01 +0100 Subject: [PATCH] [IMP] Port tests to v8 as well Conflicts: crm_claim_rma/tests/test_lp_1282584.py --- crm_claim_rma/tests/__init__.py | 2 +- crm_claim_rma/tests/test_lp_1282584.py | 101 ----------------- crm_claim_rma/tests/test_picking_creation.py | 113 +++++++++++++++++++ 3 files changed, 114 insertions(+), 102 deletions(-) delete mode 100644 crm_claim_rma/tests/test_lp_1282584.py create mode 100644 crm_claim_rma/tests/test_picking_creation.py diff --git a/crm_claim_rma/tests/__init__.py b/crm_claim_rma/tests/__init__.py index ffaaabfb..0cc244e0 100644 --- a/crm_claim_rma/tests/__init__.py +++ b/crm_claim_rma/tests/__init__.py @@ -18,4 +18,4 @@ # along with this program. If not, see . # ############################################################################## -from . import test_lp_1282584 +from . import test_picking_creation diff --git a/crm_claim_rma/tests/test_lp_1282584.py b/crm_claim_rma/tests/test_lp_1282584.py deleted file mode 100644 index 9b641a7d..00000000 --- a/crm_claim_rma/tests/test_lp_1282584.py +++ /dev/null @@ -1,101 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author: Yannick Vaucher -# Copyright 2014 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## -from openerp.tests.common import TransactionCase - - -class test_lp_1282584(TransactionCase): - """ Test wizard open the right type of view - - The wizard can generate picking.in and picking.out - Let's ensure it open the right view for each picking type - """ - - def setUp(self): - super(test_lp_1282584, self).setUp() - - self.wizard_make_picking_obj = self.env['claim_make_picking.wizard'] - line_obj = self.env['claim.line'] - claim_obj = self.env['crm.claim'] - - self.product = self.env.ref('product.product_product_4') - - self.partner = self.env.ref('base.res_partner_12') - - # Create the claim with a claim line - self.claim = claim_obj.create( - { - 'name': 'TEST CLAIM', - 'code': 'TEST CLAIM', - 'claim_type': 'customer', - 'delivery_address_id': self.partner.id, - } - ) - - self.warehouse = self.claim.warehouse_id - self.claim_line = line_obj.create( - { - 'name': 'TEST CLAIM LINE', - 'claim_origine': 'none', - 'product_id': self.product.id, - 'claim_id': self.claim.id, - 'location_dest_id': self.warehouse.lot_stock_id.id - } - ) - - def test_00(self): - """ Test wizard opened view model for a new product return """ - context = { - 'active_id': self.claim.id, - 'partner_id': self.partner.id, - 'warehouse_id': self.warehouse.id, - 'picking_type': 'in', - } - - wizard = self.wizard_make_picking_obj.with_context(context).create({}) - - res = wizard.action_create_picking() - self.assertEquals(res.get('res_model'), 'stock.picking', - "Wrong model defined") - - def test_01(self): - """ Test wizard opened view model for a new delivery """ - - wizard_change_product_qty_obj = self.env['stock.change.product.qty'] - context = {'active_id': self.product.id} - wizard_change_product_qty = wizard_change_product_qty_obj.create({ - 'product_id': self.product.id, - 'new_quantity': 12 - }) - - wizard_change_product_qty.with_context(context).change_product_qty() - - context = { - 'active_id': self.claim.id, - 'partner_id': self.partner.id, - 'warehouse_id': self.warehouse.id, - 'picking_type': 'out', - } - - wizard = self.wizard_make_picking_obj.with_context(context).create({}) - - res = wizard.action_create_picking() - self.assertEquals(res.get('res_model'), 'stock.picking', - "Wrong model defined") diff --git a/crm_claim_rma/tests/test_picking_creation.py b/crm_claim_rma/tests/test_picking_creation.py new file mode 100644 index 00000000..2ef489e6 --- /dev/null +++ b/crm_claim_rma/tests/test_picking_creation.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Yannick Vaucher +# Copyright 2014 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.tests import common + + +class test_picking_creation(common.TransactionCase): + """ Test the correct pickings are created by the wizard. """ + + def setUp(self): + super(test_picking_creation, self).setUp() + + self.WizardMakePicking = self.env['claim_make_picking.wizard'] + self.StockPicking = self.env['stock.picking'] + ClaimLine = self.env['claim.line'] + Claim = self.env['crm.claim'] + + self.product_id = self.env.ref('product.product_product_4') + + self.partner_id = self.env.ref('base.res_partner_12') + + self.customer_location_id = self.env.ref( + 'stock.stock_location_customers') + + # Create the claim with a claim line + self.claim_id = Claim.create( + { + 'name': 'TEST CLAIM', + 'number': 'TEST CLAIM', + 'claim_type': 'customer', + 'delivery_address_id': self.partner_id.id, + }) + + self.warehouse_id = self.claim_id.warehouse_id + self.claim_line_id = ClaimLine.create( + { + 'name': 'TEST CLAIM LINE', + 'claim_origine': 'none', + 'product_id': self.product_id.id, + 'claim_id': self.claim_id.id, + 'location_dest_id': self.warehouse_id.lot_stock_id.id, + }) + + def test_00_new_product_return(self): + """Test wizard creates a correct picking for product return + + """ + wizard = self.WizardMakePicking.with_context({ + 'active_id': self.claim_id.id, + 'partner_id': self.partner_id.id, + 'warehouse_id': self.warehouse_id.id, + 'picking_type': 'in', + }).create({}) + wizard.action_create_picking() + + self.assertEquals(len(self.claim_id.picking_ids), 1, + "Incorrect number of pickings created") + picking = self.claim_id.picking_ids[0] + + self.assertEquals(picking.location_id, self.customer_location_id, + "Incorrect source location") + self.assertEquals(picking.location_dest_id, + self.warehouse_id.lot_stock_id, + "Incorrect destination location") + + def test_01_new_delivery(self): + """Test wizard creates a correct picking for a new delivery + + """ + + WizardChangeProductQty = self.env['stock.change.product.qty'] + wizard_chg_qty = WizardChangeProductQty.with_context({ + 'active_id': self.product_id.id, + }).create({ + 'product_id': self.product_id.id, + 'new_quantity': 12, + }) + + wizard_chg_qty.change_product_qty() + + wizard = self.WizardMakePicking.with_context({ + 'active_id': self.claim_id.id, + 'partner_id': self.partner_id.id, + 'warehouse_id': self.warehouse_id.id, + 'picking_type': 'out', + }).create({}) + wizard.action_create_picking() + + self.assertEquals(len(self.claim_id.picking_ids), 1, + "Incorrect number of pickings created") + picking = self.claim_id.picking_ids[0] + + self.assertEquals(picking.location_id, self.warehouse_id.lot_stock_id, + "Incorrect source location") + self.assertEquals(picking.location_dest_id, self.customer_location_id, + "Incorrect destination location")