From a2667833c97b32b6dbdff4ee6ef79d7b995c0105 Mon Sep 17 00:00:00 2001 From: edescalona Date: Wed, 25 Dec 2024 15:59:52 -0500 Subject: [PATCH] [IMP] Add tests --- stock_barcodes/tests/common.py | 15 +++++++++++++++ stock_barcodes/tests/test_stock_barcodes.py | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/stock_barcodes/tests/common.py b/stock_barcodes/tests/common.py index 81067fb8f541..6bcf54a1f92e 100644 --- a/stock_barcodes/tests/common.py +++ b/stock_barcodes/tests/common.py @@ -24,6 +24,7 @@ def setUpClass(cls): cls.StockProductionLot = cls.env["stock.lot"] cls.StockPicking = cls.env["stock.picking"] cls.StockQuant = cls.env["stock.quant"] + cls.StockBarcodeAction = cls.env["stock.barcodes.action"] cls.company = cls.env.company @@ -104,6 +105,20 @@ def setUpClass(cls): {"option_group_id": cls.option_group.id, "step": 1} ) + # Barcode actions + cls.barcode_action_valid = cls.StockBarcodeAction.create( + { + "name": "Barcode action valid", + "action_window_id": cls.env.ref("stock.stock_picking_type_action").id, + } + ) + + cls.barcode_action_invalid = cls.StockBarcodeAction.create( + { + "name": "Barcode action valid", + } + ) + @classmethod def _create_barcode_option_group(cls): return cls.env["stock.barcodes.option.group"].create( diff --git a/stock_barcodes/tests/test_stock_barcodes.py b/stock_barcodes/tests/test_stock_barcodes.py index 97dda779c6f2..0583eb35e464 100644 --- a/stock_barcodes/tests/test_stock_barcodes.py +++ b/stock_barcodes/tests/test_stock_barcodes.py @@ -75,3 +75,14 @@ def test_wiz_clean_lot(self): self.action_barcode_scanned(self.wiz_scan, "8411822222568") self.wiz_scan.action_clean_lot() self.assertFalse(self.wiz_scan.lot_id) + + def test_barcode_action(self): + self.assertTrue(self.barcode_action_valid.action_window_id) + self.assertEqual(bool(self.barcode_action_invalid.action_window_id), False) + + def test_action_back(self): + result = self.wiz_scan.action_back() + self.assertIn("name", result) + self.assertIn("type", result) + self.assertIn("res_model", result) + self.assertEqual(result["type"], "ir.actions.act_window")