Skip to content

Commit

Permalink
[REF] stock_analytic: split test utilities into shareable base class
Browse files Browse the repository at this point in the history
Needed to also rename method starting with double-underscrore to
avoid Python method name mangling.
  • Loading branch information
aisopuro committed Sep 5, 2024
1 parent 59166f3 commit 8488449
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions stock_analytic/tests/test_stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from odoo.tests.common import TransactionCase


class TestStockPicking(TransactionCase):
class CommonStockPicking(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down Expand Up @@ -118,7 +118,7 @@ def _create_picking(

return picking

def __update_qty_on_hand_product(self, product, new_qty):
def _update_qty_on_hand_product(self, product, new_qty):
self.env["stock.quant"]._update_available_quantity(
product, self.location, new_qty
)
Expand Down Expand Up @@ -157,14 +157,16 @@ def _check_no_analytic_account(self, picking):
line_count = self.env["account.move.line"].search_count(criteria2)
self.assertEqual(line_count, 0)


class TestStockPicking(CommonStockPicking):
def test_outgoing_picking_with_analytic(self):
picking = self._create_picking(
self.location,
self.dest_location,
self.outgoing_picking_type,
self.analytic_distribution,
)
self.__update_qty_on_hand_product(self.product, 1)
self._update_qty_on_hand_product(self.product, 1)
self._confirm_picking_no_error(picking)
self._picking_done_no_error(picking)
self._check_account_move_no_error(picking)
Expand All @@ -176,7 +178,7 @@ def test_outgoing_picking_without_analytic_optional(self):
self.dest_location,
self.outgoing_picking_type,
)
self.__update_qty_on_hand_product(self.product, 1)
self._update_qty_on_hand_product(self.product, 1)
self._confirm_picking_no_error(picking)
self._picking_done_no_error(picking)
self._check_account_move_no_error(picking)
Expand All @@ -189,7 +191,7 @@ def test_outgoing_picking_without_analytic_mandatory(self):
self.dest_location,
self.outgoing_picking_type,
)
self.__update_qty_on_hand_product(self.product, 1)
self._update_qty_on_hand_product(self.product, 1)
self._confirm_picking_no_error(picking)
with self.assertRaises(ValidationError):
self._picking_done_no_error(picking)
Expand All @@ -201,7 +203,7 @@ def test_incoming_picking_with_analytic(self):
self.incoming_picking_type,
self.analytic_distribution,
)
self.__update_qty_on_hand_product(self.product, 1)
self._update_qty_on_hand_product(self.product, 1)
self._confirm_picking_no_error(picking)
self._picking_done_no_error(picking)
self._check_account_move_no_error(picking)
Expand Down

0 comments on commit 8488449

Please sign in to comment.