Commit 34993fae authored by Sebastien Robin's avatar Sebastien Robin

- fix a very old small error that makes impossible to call a builder

  safely several time (we have to look if there is delivery link
  from the simulation movement to a non simulation document) 
- add unit test in order to make sure that we can call a builder
  2 times in the same transaction without any problem


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26512 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 04e0b6a6
...@@ -129,7 +129,7 @@ class DeliveryBuilder(OrderBuilder): ...@@ -129,7 +129,7 @@ class DeliveryBuilder(OrderBuilder):
movement_list = select_method(**kw) movement_list = select_method(**kw)
# XXX Use buildSQLQuery will be better # XXX Use buildSQLQuery will be better
movement_list = [x for x in movement_list if \ movement_list = [x for x in movement_list if \
x.getDeliveryRelatedValueList()==[]] x.getDeliveryValueList()==[]]
# XXX Add predicate test # XXX Add predicate test
# XXX FIXME Check that there is no double in the list # XXX FIXME Check that there is no double in the list
# Because we can't trust simulation_select_method # Because we can't trust simulation_select_method
......
...@@ -65,6 +65,17 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -65,6 +65,17 @@ class TestPackingListMixin(TestOrderMixin):
stepCheckPackingListIsNotDivergent \ stepCheckPackingListIsNotDivergent \
stepCheckOrderPackingList ' stepCheckOrderPackingList '
confirmed_order_without_packing_list = default_order_sequence + '\
stepCreateNotVariatedResource \
stepTic \
stepCreateOrderLine \
stepSetOrderLineResource \
stepSetOrderLineDefaultValues \
stepOrderOrder \
stepTic \
stepConfirmOrder \
stepTic '
default_sequence_with_duplicated_lines = default_order_sequence + '\ default_sequence_with_duplicated_lines = default_order_sequence + '\
stepCreateNotVariatedResource \ stepCreateNotVariatedResource \
stepTic \ stepTic \
...@@ -1337,6 +1348,37 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) : ...@@ -1337,6 +1348,37 @@ class TestPackingList(TestPackingListMixin, ERP5TypeTestCase) :
if err_list: if err_list:
self.fail(''.join(err_list)) self.fail(''.join(err_list))
def test_15_CheckBuilderCanBeCalledTwiveSafely(self):
"""
Builder design should allows to call the build method as many times as we
want. Make sure that we will not have duplicated packing list if build is
called several times.
"""
delivery_builder = getattr(self.getPortalObject().portal_deliveries,
self.delivery_builder_id)
def doNothing(self, *args, **kw):
pass
original_delivery_builder_build = delivery_builder.__class__.build
try:
# We patch the delivery builder to make sure that it will not be
# called by activities
delivery_builder.__class__.build = doNothing
sequence_list = SequenceList()
# Test with a simply order without cell
sequence_string = self.confirmed_order_without_packing_list
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
# Now restore the build method and make sure first call returns document
delivery_builder.__class__.build = original_delivery_builder_build
self.assertTrue(len(delivery_builder.build()) > 0)
# The second call should returns empty result even if tic not called
self.assertTrue(len(delivery_builder.build()) == 0)
finally:
delivery_builder.build = original_delivery_builder_build
class TestPurchasePackingListMixin(TestPackingListMixin): class TestPurchasePackingListMixin(TestPackingListMixin):
"""Mixing class with steps to test purchase packing lists. """Mixing class with steps to test purchase packing lists.
......
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