Commit e55f8a00 authored by Łukasz Nowak's avatar Łukasz Nowak

- proved, that it is possible to deliver all production packing lists and...

 - proved, that it is possible to deliver all production packing lists and production reports based on sourcing production oreder (and that it is, what I wanted this test to be on initial revision)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22035 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 810c8b04
...@@ -40,45 +40,6 @@ class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPacking ...@@ -40,45 +40,6 @@ class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPacking
ERP5TypeTestCase): ERP5TypeTestCase):
"""Mixin for testing Production Packing Lists and Production Reports""" """Mixin for testing Production Packing Lists and Production Reports"""
def stepCreatePackingList(self,sequence=None, sequence_list=None, **kw):
"""
Create a empty packing_list
"""
organisation = sequence.get('organisation')
# person = sequence.get('person')
portal = self.getPortal()
packing_list_module = portal.getDefaultModule(portal_type=self.packing_list_portal_type)
packing_list = packing_list_module.newContent(portal_type=self.packing_list_portal_type)
packing_list.edit(
title = "PackingList",
start_date = self.datetime + 10,
stop_date = self.datetime + 20,
)
if organisation is not None:
packing_list.edit(source_value=organisation,
source_section_value=organisation,
destination_value=organisation,
destination_section_value=organisation,
source_decision_value=organisation,
destination_decision_value=organisation,
source_administration_value=organisation,
destination_administration_value=organisation,
)
sequence.edit( packing_list = packing_list )
def stepSetPackingListProfile(self,sequence=None, sequence_list=None, **kw):
"""
Set different source and destination on the packing_list
"""
organisation1 = sequence.get('organisation1')
organisation2 = sequence.get('organisation2')
packing_list = sequence.get('packing_list')
packing_list.edit( source_value = organisation1,
source_section_value = organisation1,
destination_value = organisation2,
destination_section_value = organisation2 )
self.failUnless('Site Error' not in packing_list.view())
def modifyPackingListState(self, transition_name, def modifyPackingListState(self, transition_name,
sequence,packing_list=None): sequence,packing_list=None):
""" calls the workflow for the packing list """ """ calls the workflow for the packing list """
...@@ -86,134 +47,388 @@ class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPacking ...@@ -86,134 +47,388 @@ class TestProductionPackingReportListMixin(TestProductionOrderMixin, TestPacking
packing_list = sequence.get('packing_list') packing_list = sequence.get('packing_list')
packing_list.portal_workflow.doActionFor(packing_list, transition_name) packing_list.portal_workflow.doActionFor(packing_list, transition_name)
def stepConfirmPackingList(self, sequence=None, sequence_list=None, **kw): def stepSetReadyProducedDeliveryPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('confirm_action', sequence=sequence) packing_list = sequence.get('produced_delivery_packing_list')
packing_list = sequence.get('packing_list') self.modifyPackingListState('set_ready_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'confirmed') self.assertEquals(packing_list.getSimulationState(), 'ready')
def stepSetReadyPackingList(self, sequence=None, sequence_list=None, **kw): def stepStartProducedDeliveryPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('set_ready_action', sequence=sequence) packing_list = sequence.get('produced_delivery_packing_list')
packing_list = sequence.get('packing_list') self.modifyPackingListState('start_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'started')
def stepStopProducedDeliveryPackingList(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('produced_delivery_packing_list')
self.modifyPackingListState('stop_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'stopped')
def stepDeliverProducedDeliveryPackingList(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('produced_delivery_packing_list')
self.modifyPackingListState('deliver_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'delivered')
def stepSetReadySupplyDeliveryPackingList(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('supply_delivery_packing_list')
self.modifyPackingListState('set_ready_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'ready') self.assertEquals(packing_list.getSimulationState(), 'ready')
def stepStartPackingList(self, sequence=None, sequence_list=None, **kw): def stepStartSupplyDeliveryPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('start_action', sequence=sequence) packing_list = sequence.get('supply_delivery_packing_list')
packing_list = sequence.get('packing_list') self.modifyPackingListState('start_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'started') self.assertEquals(packing_list.getSimulationState(), 'started')
def stepStopPackingList(self, sequence=None, sequence_list=None, **kw): def stepStopSupplyDeliveryPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('stop_action', sequence=sequence) packing_list = sequence.get('supply_delivery_packing_list')
packing_list = sequence.get('packing_list') self.modifyPackingListState('stop_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'stopped') self.assertEquals(packing_list.getSimulationState(), 'stopped')
def stepDeliverPackingList(self, sequence=None, sequence_list=None, **kw): def stepDeliverSupplyDeliveryPackingList(self, sequence=None, sequence_list=None, **kw):
self.modifyPackingListState('deliver_action', sequence=sequence) packing_list = sequence.get('supply_delivery_packing_list')
packing_list = sequence.get('packing_list') self.modifyPackingListState('deliver_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'delivered') self.assertEquals(packing_list.getSimulationState(), 'delivered')
def stepCreatePackingListLine(self,sequence=None, sequence_list=None, **kw): def stepSetReadyProducedReport(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('produced_report')
self.modifyPackingListState('set_ready_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'ready')
def stepStartProducedReport(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('produced_report')
self.modifyPackingListState('start_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'started')
def stepStopProducedReport(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('produced_report')
self.modifyPackingListState('stop_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'stopped')
def stepDeliverProducedReport(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('produced_report')
self.modifyPackingListState('deliver_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'delivered')
def stepSetReadyConsumedReport(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('consumed_report')
self.modifyPackingListState('set_ready_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'ready')
def stepStartConsumedReport(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('consumed_report')
self.modifyPackingListState('start_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'started')
def stepStopConsumedReport(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('consumed_report')
self.modifyPackingListState('stop_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'stopped')
def stepDeliverConsumedReport(self, sequence=None, sequence_list=None, **kw):
packing_list = sequence.get('consumed_report')
self.modifyPackingListState('deliver_action', sequence=sequence, packing_list=packing_list)
self.assertEquals(packing_list.getSimulationState(), 'delivered')
def stepCheckSourcingDeliverySimulation(self, sequence=None, \
sequence_list=None, **kw):
""" """
Create a empty packing_list line Hardcoded delivery checks
""" """
packing_list = sequence.get('packing_list') self.stepCheckSourcingSimulation(sequence,sequence_list,**kw)
packing_list_line = packing_list.newContent(portal_type=self.packing_list_line_portal_type)
packing_list_line.edit( produced_movement = sequence.get('produced_movement')
title = "PackingList Line" operation_movement = sequence.get('operation_movement')
component_movement = sequence.get('component_movement')
supply_movement = sequence.get('supply_movement')
produced_delivery_movement = sequence.get('produced_delivery_movement')
produced_delivery_packing_list = produced_delivery_movement.getDeliveryValue().getParentValue()
supply_delivery_packing_list = supply_movement.getDeliveryValue().getParentValue()
produced_report = produced_movement.getDeliveryValue().getParentValue()
operation_report = operation_movement.getDeliveryValue().getParentValue()
component_report = component_movement.getDeliveryValue().getParentValue()
self.assertEquals(operation_report, component_report)
consumed_report = operation_report
# checks that simulations are same
# TODO: resources, quantities, dates, ...
self.assertEquals(
produced_delivery_movement.getSimulationState(),
produced_delivery_packing_list.getSimulationState()
) )
sequence.edit(packing_list_line=packing_list_line)
def stepSetPackingListLineResource(self, sequence=None, sequence_list=None, **kw): self.assertEquals(
""" supply_movement.getSimulationState(),
Set packing_list line resource with the current resource supply_delivery_packing_list.getSimulationState()
""" )
packing_list_line = sequence.get('packing_list_line')
resource = sequence.get('resource') self.assertEquals(
packing_list_line.setResourceValue(resource) produced_movement.getSimulationState(),
produced_report.getSimulationState()
)
self.assertEquals(
component_movement.getSimulationState(),
consumed_report.getSimulationState()
)
self.assertEquals(
operation_movement.getSimulationState(),
consumed_report.getSimulationState()
)
sequence.edit(
produced_delivery_packing_list = produced_delivery_packing_list,
supply_delivery_packing_list = supply_delivery_packing_list,
produced_report = produced_report,
consumed_report = consumed_report,
)
def stepSetPackingListLineDefaultValues(self, sequence=None, \ def stepCheckProducedDeliveryPackingListConfirmed(self, sequence=None, \
sequence_list=None, **kw): sequence_list=None, **kw):
""" packing_list = sequence.get('produced_delivery_packing_list')
Set the default price and quantity on the packing_list line.
"""
packing_list_line = sequence.get('packing_list_line')
packing_list_line.edit(quantity=self.default_quantity,
price=self.default_price)
def stepCheckPackingListSimulation(self, sequence=None, \ self.assertEquals(
'confirmed',
packing_list.getSimulationState()
)
def stepCheckProducedDeliveryPackingListDelivered(self, sequence=None, \
sequence_list=None, **kw): sequence_list=None, **kw):
packing_list = sequence.get('packing_list') packing_list = sequence.get('produced_delivery_packing_list')
applied_rule = packing_list.getCausalityRelatedValueList(portal_type=\ self.assertEquals(
self.applied_rule_portal_type) 'delivered',
self.logMessage("TODO") packing_list.getSimulationState()
)
class TestProductionPackingListReport(TestProductionPackingReportListMixin): def stepCheckSupplyDeliveryPackingListDelivered(self, sequence=None, \
pass sequence_list=None, **kw):
packing_list = sequence.get('supply_delivery_packing_list')
class TestProductionPackingList(TestProductionPackingReportListMixin): self.assertEquals(
"""Test Production Packing Lists""" 'delivered',
run_all_test = 1 packing_list.getSimulationState()
)
def stepCheckProducedReportDelivered(self, sequence=None, \
sequence_list=None, **kw):
packing_list = sequence.get('produced_report')
self.assertEquals(
'delivered',
packing_list.getSimulationState()
)
def stepCheckConsumedReportDelivered(self, sequence=None, \
sequence_list=None, **kw):
packing_list = sequence.get('consumed_report')
self.assertEquals(
'delivered',
packing_list.getSimulationState()
)
packing_list_portal_type = 'Production Packing List' def stepCheckProducedDeliveryPackingListSolved(self, sequence=None, \
packing_list_line_portal_type = 'Production Packing List Line' sequence_list=None, **kw):
packing_list_cell_portal_type = 'Production Packing List Cell' packing_list = sequence.get('produced_delivery_packing_list')
self.assertEquals(
'solved',
packing_list.getCausalityState()
)
def stepCheckSupplyDeliveryPackingListConfirmed(self, sequence=None, \
sequence_list=None, **kw):
packing_list = sequence.get('supply_delivery_packing_list')
self.assertEquals(
'confirmed',
packing_list.getSimulationState()
)
def stepCheckSupplyDeliveryPackingListSolved(self, sequence=None, \
sequence_list=None, **kw):
packing_list = sequence.get('supply_delivery_packing_list')
def getTitle(self): self.assertEquals(
return "Production Packing List" 'solved',
packing_list.getCausalityState()
)
def stepCheckProducedReportConfirmed(self, sequence=None, \
sequence_list=None, **kw):
packing_list = sequence.get('produced_report')
self.assertEquals(
'confirmed',
packing_list.getSimulationState()
)
def stepCheckProducedReportSolved(self, sequence=None, \
sequence_list=None, **kw):
packing_list = sequence.get('produced_report')
self.assertEquals(
'solved',
packing_list.getCausalityState()
)
def test_01_checkForProductionPackingListWorkflow(self, quiet=0, run=run_all_test): def stepCheckConsumedReportConfirmed(self, sequence=None, \
sequence_list=None, **kw):
packing_list = sequence.get('consumed_report')
self.assertEquals(
'confirmed',
packing_list.getSimulationState()
)
def stepCheckConsumedReportSolved(self, sequence=None, \
sequence_list=None, **kw):
packing_list = sequence.get('consumed_report')
self.assertEquals(
'solved',
packing_list.getCausalityState()
)
class TestProductionDelivery(TestProductionPackingReportListMixin):
"""Test Production Packing Lists and Reports, mostly based on Production Orders"""
run_all_test = 1
def test_01_sourcingDelivery(self, quiet=0,
run=run_all_test):
""" """
Test that production packing list workflow works, and updates simulations Test for sourcing type of delivery (Production Report and Production Packing Lists).
""" """
if not run: return if not run: return
sequence_list = SequenceList() sequence_list = SequenceList()
# Test when order is # Check states of deliveries, just after order confirmation
sequence_string = '\ sequence_string = self.SOURCING_ORDER_SEQUENCE + '\
stepCreateOrganisation1 \ CheckSourcingDeliverySimulation \
stepCreateOrganisation2 \ \
stepClearActivities \ CheckProducedDeliveryPackingListConfirmed \
stepCreatePackingList \ CheckProducedDeliveryPackingListSolved\
stepSetPackingListProfile \ \
stepCreateNotVariatedResource \ CheckSupplyDeliveryPackingListConfirmed \
stepTic \ CheckSupplyDeliveryPackingListSolved\
stepCreatePackingListLine \ \
stepSetPackingListLineResource \ CheckProducedReportConfirmed \
stepSetPackingListLineDefaultValues \ CheckProducedReportSolved\
stepTic \ \
\ CheckConsumedReportConfirmed \
stepConfirmPackingList \ CheckConsumedReportSolved\
stepTic \ \
\ '
stepSetReadyPackingList \
stepTic \
\
stepStartPackingList \
stepTic \
\
stepStopPackingList \
stepTic \
\
stepDeliverPackingList \
stepTic \
'
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
class TestProductionReport(TestProductionPackingList):
"""Test Production Reports"""
run_all_test = 1
def getTitle(self): # Test when packing list are delivered one by one
return "Production Report" # Note: I (Luke) know, that below sequence is long
# but I wanted to be sure, that full production
# process is doable.
sequence_string = self.SOURCING_ORDER_SEQUENCE + '\
CheckSourcingDeliverySimulation \
\
CheckProducedDeliveryPackingListConfirmed \
CheckProducedDeliveryPackingListSolved\
\
CheckSupplyDeliveryPackingListConfirmed \
CheckSupplyDeliveryPackingListSolved\
\
CheckProducedReportConfirmed \
CheckProducedReportSolved\
\
CheckConsumedReportConfirmed \
CheckConsumedReportSolved\
\
SetReadyProducedDeliveryPackingList \
StartProducedDeliveryPackingList \
StopProducedDeliveryPackingList \
DeliverProducedDeliveryPackingList \
Tic \
\
CheckSourcingDeliverySimulation \
\
CheckProducedDeliveryPackingListDelivered \
CheckProducedDeliveryPackingListSolved\
\
CheckSupplyDeliveryPackingListConfirmed \
CheckSupplyDeliveryPackingListSolved\
\
CheckProducedReportConfirmed \
CheckProducedReportSolved\
\
CheckConsumedReportConfirmed \
CheckConsumedReportSolved\
\
SetReadySupplyDeliveryPackingList \
StartSupplyDeliveryPackingList \
StopSupplyDeliveryPackingList \
DeliverSupplyDeliveryPackingList \
Tic \
\
CheckSourcingDeliverySimulation \
\
CheckProducedDeliveryPackingListDelivered \
CheckProducedDeliveryPackingListSolved\
\
CheckSupplyDeliveryPackingListDelivered \
CheckSupplyDeliveryPackingListSolved\
\
CheckProducedReportConfirmed \
CheckProducedReportSolved\
\
CheckConsumedReportConfirmed \
CheckConsumedReportSolved\
\
SetReadyProducedReport \
StartProducedReport \
StopProducedReport \
DeliverProducedReport \
Tic \
\
CheckSourcingDeliverySimulation \
\
CheckProducedDeliveryPackingListDelivered \
CheckProducedDeliveryPackingListSolved\
\
CheckSupplyDeliveryPackingListDelivered \
CheckSupplyDeliveryPackingListSolved\
\
CheckProducedReportDelivered \
CheckProducedReportSolved\
\
CheckConsumedReportConfirmed \
CheckConsumedReportSolved\
\
SetReadyConsumedReport \
StartConsumedReport \
StopConsumedReport \
DeliverConsumedReport \
Tic \
\
CheckSourcingDeliverySimulation \
\
CheckProducedDeliveryPackingListDelivered \
CheckProducedDeliveryPackingListSolved\
\
CheckSupplyDeliveryPackingListDelivered \
CheckSupplyDeliveryPackingListSolved\
\
CheckProducedReportDelivered \
CheckProducedReportSolved\
\
CheckConsumedReportDelivered \
CheckConsumedReportSolved\
\
'
sequence_list.addSequenceString(sequence_string)
packing_list_portal_type = 'Production Report' # TODO: check case of solving divergence on every delivery
packing_list_line_portal_type = 'Production Report Line' sequence_list.play(self)
packing_list_cell_portal_type = 'Production Report Cell'
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestProductionPackingListReport)) suite.addTest(unittest.makeSuite(TestProductionDelivery))
#suite.addTest(unittest.makeSuite(TestProductionPackingList))
#suite.addTest(unittest.makeSuite(TestProductionReport))
return suite return suite
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