Commit 2c2d8713 authored by Jérome Perrin's avatar Jérome Perrin

Add tests for getQuantity on Container, Container Line and Container Cell

Fix error on Container.getQuantity


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24961 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 399482cb
...@@ -83,7 +83,7 @@ class Container(Movement, XMLObject): ...@@ -83,7 +83,7 @@ class Container(Movement, XMLObject):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getQuantity') 'getQuantity')
def getQuantity(self): def getQuantity(self, default=1.0):
""" """
Returns 1 because only one container is shipped Returns 1 because only one container is shipped
""" """
......
...@@ -745,6 +745,16 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -745,6 +745,16 @@ class TestPackingListMixin(TestOrderMixin):
container_line = sequence.get('container_line') container_line = sequence.get('container_line')
container_line.edit(quantity=self.default_quantity-1) container_line.edit(quantity=self.default_quantity-1)
def stepCheckContainerLineSmallQuantity(self, sequence=None,
sequence_list=None, **kw):
"""
Checks that quantity is set correctly on the container_line.
"""
container_line = sequence.get('container_line')
self.assertEquals(self.default_quantity - 1, container_line.getQuantity())
self.assertEquals(self.default_quantity - 1,
container_line.getTotalQuantity())
def stepSetContainerLineFullQuantity(self,sequence=None, sequence_list=None, def stepSetContainerLineFullQuantity(self,sequence=None, sequence_list=None,
quantity=None,**kw): quantity=None,**kw):
""" """
...@@ -777,6 +787,8 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -777,6 +787,8 @@ class TestPackingListMixin(TestOrderMixin):
quantity = line.getQuantity() quantity = line.getQuantity()
container_line.edit(quantity=quantity) container_line.edit(quantity=quantity)
container_line.immediateReindexObject() container_line.immediateReindexObject()
self.assertEquals(quantity, container_line.getQuantity())
self.assertEquals(quantity, container_line.getTotalQuantity())
# with variation # with variation
elif line.hasCellContent(): elif line.hasCellContent():
vcl = line.getVariationCategoryList() vcl = line.getVariationCategoryList()
...@@ -796,6 +808,15 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -796,6 +808,15 @@ class TestPackingListMixin(TestOrderMixin):
predicate_category_list=cell_key, predicate_category_list=cell_key,
variation_category_list=cell_key) variation_category_list=cell_key)
cell.immediateReindexObject() cell.immediateReindexObject()
self.assertEquals(old_cell.getQuantity(), cell.getQuantity())
self.assertEquals(old_cell.getTotalQuantity(), cell.getTotalQuantity())
self.assertEquals(line.getQuantity(), container_line.getQuantity())
self.assertEquals(line.getTotalQuantity(), container_line.getTotalQuantity())
# quantity is 1 on the container itself
self.assertEquals(1, container.getQuantity())
self.assertEquals(1, container.getTotalQuantity())
def stepCheckPackingListIsNotPacked(self,sequence=None, sequence_list=None, **kw): def stepCheckPackingListIsNotPacked(self,sequence=None, sequence_list=None, **kw):
""" """
...@@ -1151,6 +1172,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -1151,6 +1172,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
stepAddPackingListContainer \ stepAddPackingListContainer \
stepAddPackingListContainerLine \ stepAddPackingListContainerLine \
stepSetContainerLineSmallQuantity \ stepSetContainerLineSmallQuantity \
stepCheckContainerLineSmallQuantity \
stepCheckPackingListIsNotPacked \ stepCheckPackingListIsNotPacked \
stepSetContainerFullQuantity \ stepSetContainerFullQuantity \
stepTic \ stepTic \
...@@ -1170,6 +1192,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -1170,6 +1192,7 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
stepAddPackingListContainer \ stepAddPackingListContainer \
stepAddPackingListContainerLine \ stepAddPackingListContainerLine \
stepSetContainerLineSmallQuantity \ stepSetContainerLineSmallQuantity \
stepCheckContainerLineSmallQuantity \
stepCheckPackingListIsNotPacked \ stepCheckPackingListIsNotPacked \
stepSetContainerFullQuantity \ stepSetContainerFullQuantity \
stepTic \ stepTic \
...@@ -1336,6 +1359,7 @@ class TestPurchasePackingListMixin(TestPackingListMixin): ...@@ -1336,6 +1359,7 @@ class TestPurchasePackingListMixin(TestPackingListMixin):
stepDefineNewPackingListContainer = ignored_step stepDefineNewPackingListContainer = ignored_step
stepAddPackingListContainerLine = ignored_step stepAddPackingListContainerLine = ignored_step
stepSetContainerLineSmallQuantity = ignored_step stepSetContainerLineSmallQuantity = ignored_step
stepCheckContainerLineSmallQuantity = ignored_step
stepSetContainerLineFullQuantity = ignored_step stepSetContainerLineFullQuantity = ignored_step
stepSetContainerFullQuantity = ignored_step stepSetContainerFullQuantity = ignored_step
stepCheckPackingListIsNotPacked = ignored_step stepCheckPackingListIsNotPacked = ignored_step
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment