Skip to content

Commit

Permalink
[IMP] stock_location_zone: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rousseldenis committed Dec 7, 2022
1 parent 525f420 commit b33e158
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions stock_location_zone/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_stock_location_zone
62 changes: 62 additions & 0 deletions stock_location_zone/tests/test_stock_location_zone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright 2022 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase


class TestStockLocationZone(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.location_obj = cls.env["stock.location"]
# Create the following structure:
# # [Zone Location]
# # # [Area Location]
# # # # [Bin Location]
cls.location_zone = cls.location_obj.create(
{
"name": "Zone Location",
"is_zone": True,
}
)
cls.location_area = cls.location_obj.create(
{"name": "Area Location", "location_id": cls.location_zone.id}
)
cls.location_bin = cls.location_obj.create(
{"name": "Bin Location", "location_id": cls.location_area.id}
)
cls.scrap_location = cls.location_obj.create(
{
"name": "Scrap Location",
"usage": "inventory",
}
)
cls.stock_location = cls.env.ref("stock.warehouse0").lot_stock_id

def test_location_kind(self):
self.assertEqual("zone", self.location_zone.location_kind)
self.assertEqual("area", self.location_area.location_kind)
self.assertEqual("bin", self.location_bin.location_kind)
self.assertEqual("stock", self.stock_location.location_kind)
self.assertEqual("other", self.scrap_location.location_kind)

def test_location_zone(self):
# Check that Zone Location has:
# # The zone location as self
# # No area location
self.assertEqual(
self.location_zone.zone_location_id,
self.location_zone,
)
self.assertFalse(self.location_zone.area_location_id)
# Check that Area Location has:
# # The zone location is Zone Location
# # The area location is self
self.assertEqual(self.location_zone, self.location_area.zone_location_id)
self.assertEqual(self.location_area, self.location_area.area_location_id)
# Check the Bin Location
# # The zone location is Zone Location
# # The area location is Area Location
self.assertEqual(self.location_zone, self.location_bin.zone_location_id)
self.assertEqual(self.location_area, self.location_bin.area_location_id)

0 comments on commit b33e158

Please sign in to comment.