Skip to content

Commit

Permalink
[IMP] stock_release_channel_show_volume
Browse files Browse the repository at this point in the history
Make one test per test
  • Loading branch information
jbaudoux committed Mar 4, 2024
1 parent 7161630 commit 47e8646
Showing 1 changed file with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2023 Michael Tietz (MT Software) <[email protected]>
# Copyright 2024 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from datetime import timedelta
Expand Down Expand Up @@ -40,10 +41,7 @@ def assertVolumeFullProgress(self):
),
)

def test_computed_fields_counts(self):
picking = self.picking

self.channel.invalidate_cache()
def test_computed_fields_counts_not_ready(self):
self.assertVolume("all", [(self.product1, 5 * 3), (self.product2, 5 * 3)])
self.assertVolume("release_ready", [])
self.assertVolume("released", [])
Expand All @@ -54,10 +52,10 @@ def test_computed_fields_counts(self):
self.assertVolume("done", [])
self.assertVolumeFullProgress()

def test_computed_fields_counts_release_ready(self):
self._update_qty_in_location(self.loc_bin1, self.product1, 20.0)
self._update_qty_in_location(self.loc_bin1, self.product2, 20.0)

self.channel.invalidate_cache()
self.assertVolume("all", [(self.product1, 5 * 3), (self.product2, 5 * 3)])
self.assertVolume(
"release_ready", [(self.product1, 5 * 3), (self.product2, 5 * 3)]
Expand All @@ -70,10 +68,11 @@ def test_computed_fields_counts(self):
self.assertVolume("done", [])
self.assertVolumeFullProgress()

picking.release_available_to_promise()
pick_picking = picking.move_lines.move_orig_ids.picking_id
def test_computed_fields_counts_released(self):
self._update_qty_in_location(self.loc_bin1, self.product1, 20.0)
self._update_qty_in_location(self.loc_bin1, self.product2, 20.0)
self.picking.release_available_to_promise()

self.channel.invalidate_cache()
self.assertVolume("all", [(self.product1, 5 * 3), (self.product2, 5 * 3)])
self.assertVolume(
"release_ready", [(self.product1, 5 * 2), (self.product2, 5 * 2)]
Expand All @@ -86,8 +85,15 @@ def test_computed_fields_counts(self):
self.assertVolume("done", [])
self.assertVolumeFullProgress()

picking.scheduled_date = fields.Datetime.now() - timedelta(hours=1)
self.channel.invalidate_cache()
def test_computed_fields_counts_late(self):
self._update_qty_in_location(self.loc_bin1, self.product1, 20.0)
self._update_qty_in_location(self.loc_bin1, self.product2, 20.0)
self.picking.release_available_to_promise()
# FIXME late should measure late internal operations, not late deliveries
# pick_picking = self.picking.move_ids.move_orig_ids.picking_id
# pick_picking.scheduled_date = fields.Datetime.now() - timedelta(hours=1)
self.picking.scheduled_date = fields.Datetime.now() - timedelta(hours=1)

self.assertVolume("all", [(self.product1, 5 * 3), (self.product2, 5 * 3)])
self.assertVolume(
"release_ready", [(self.product1, 5 * 2), (self.product2, 5 * 2)]
Expand All @@ -100,24 +106,33 @@ def test_computed_fields_counts(self):
self.assertVolume("done", [])
self.assertVolumeFullProgress()

def test_computed_fields_counts_pick_done(self):
self._update_qty_in_location(self.loc_bin1, self.product1, 20.0)
self._update_qty_in_location(self.loc_bin1, self.product2, 20.0)
self.picking.release_available_to_promise()
pick_picking = self.picking.move_ids.move_orig_ids.picking_id
self._action_done_picking(pick_picking)

self.channel.invalidate_cache()
self.assertVolume("all", [(self.product1, 5 * 3), (self.product2, 5 * 3)])
self.assertVolume(
"release_ready", [(self.product1, 5 * 2), (self.product2, 5 * 2)]
)
self.assertVolume("released", [(self.product1, 5), (self.product2, 5)])
self.assertVolume("assigned", [(self.product1, 5), (self.product2, 5)])
self.assertVolume("waiting", [])
self.assertVolume("late", [(self.product1, 5), (self.product2, 5)])
self.assertVolume("late", [])
self.assertVolume("priority", [])
self.assertVolume("done", [])
self.assertVolumeFullProgress()

self._action_done_picking(picking)
def test_computed_fields_counts_ship_done(self):
self._update_qty_in_location(self.loc_bin1, self.product1, 20.0)
self._update_qty_in_location(self.loc_bin1, self.product2, 20.0)
self.picking.release_available_to_promise()
pick_picking = self.picking.move_ids.move_orig_ids.picking_id
self._action_done_picking(pick_picking)
self._action_done_picking(self.picking)

self.channel.invalidate_cache()
self.assertVolume("all", [(self.product1, 5 * 3), (self.product2, 5 * 3)])
self.assertVolume(
"release_ready", [(self.product1, 5 * 2), (self.product2, 5 * 2)]
Expand Down

0 comments on commit 47e8646

Please sign in to comment.