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

- those tests were wrong, created using incorrect assumption about movement's frozen state


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27069 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 03aefe21
...@@ -41,7 +41,7 @@ from DateTime import DateTime ...@@ -41,7 +41,7 @@ from DateTime import DateTime
from Acquisition import aq_parent from Acquisition import aq_parent
from zLOG import LOG from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from testPackingList import TestPackingListMixin, TestDeliveryRule from testPackingList import TestPackingListMixin
from testAccountingRules import TestAccountingRulesMixin from testAccountingRules import TestAccountingRulesMixin
class TestInvoiceMixin(TestPackingListMixin, class TestInvoiceMixin(TestPackingListMixin,
...@@ -3258,45 +3258,9 @@ class TestPurchaseInvoice(TestInvoice, ERP5TypeTestCase): ...@@ -3258,45 +3258,9 @@ class TestPurchaseInvoice(TestInvoice, ERP5TypeTestCase):
stepTic stepTic
""" """
class TestInvoiceRule(TestDeliveryRule):
rule_portal_type = 'Invoice Rule'
delivery_line_portal_type = 'Invoice Line'
def test_rule_simulation_ready(self):
# not available on invoice
return
def test_rule_simulation_confirm(self):
self.createDocuments()
self.delivery.plan()
self.assertEqual('planned', self.delivery.getSimulationState())
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
self.modifyDelivery()
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
class TestInvoiceRuleSaleInvoiceTransaction(TestInvoiceRule):
delivery_portal_type = 'Sale Invoice Transaction'
def getTitle(self):
return "Sale Invoice Transaction Invoice Rule"
class TestInvoiceRulePurchaseInvoiceTransaction(TestInvoiceRule):
delivery_portal_type = 'Purchase Invoice Transaction'
def getTitle(self):
return "Purchase Invoice Transaction Invoice Rule"
import unittest import unittest
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestSaleInvoice)) suite.addTest(unittest.makeSuite(TestSaleInvoice))
suite.addTest(unittest.makeSuite(TestPurchaseInvoice)) suite.addTest(unittest.makeSuite(TestPurchaseInvoice))
suite.addTest(unittest.makeSuite(TestInvoiceRuleSaleInvoiceTransaction))
suite.addTest(unittest.makeSuite(TestInvoiceRulePurchaseInvoiceTransaction))
return suite return suite
...@@ -1412,222 +1412,8 @@ class TestPurchasePackingListMixin(TestPackingListMixin): ...@@ -1412,222 +1412,8 @@ class TestPurchasePackingListMixin(TestPackingListMixin):
class TestPurchasePackingList(TestPurchasePackingListMixin, TestPackingList): class TestPurchasePackingList(TestPurchasePackingListMixin, TestPackingList):
"""Tests for purchase packing list. """Tests for purchase packing list.
""" """
class TestDeliveryRule(TestPackingListMixin, ERP5TypeTestCase):
applied_rule_portal_type = 'Applied Rule'
def createResource(self, **kw):
module = self.portal.getDefaultModule(portal_type=self.resource_portal_type)
resource = module.newContent(portal_type=self.resource_portal_type, **kw)
return resource
def createOrganisation(self, **kw):
organisation_portal_type = 'Organisation'
module = self.portal.getDefaultModule(portal_type=organisation_portal_type)
organisation = module.newContent(portal_type=organisation_portal_type, **kw)
return organisation
def createDelivery(self, **kw):
module = self.portal.getDefaultModule(portal_type=self.delivery_portal_type)
delivery = module.newContent(portal_type=self.delivery_portal_type, **kw)
return delivery
def checkDeliverySimulation(self):
delivery = self.delivery
delivery_line = self.delivery_line
applied_rule_list = delivery.getCausalityRelatedValueList(
portal_type=self.applied_rule_portal_type)
# delivery shall have one applied rule
self.assertEqual(1, len(applied_rule_list))
applied_rule = applied_rule_list[0]
self.assertEqual(self.rule_portal_type, applied_rule.getSpecialiseValue()
.getPortalType())
simulation_movement_list = applied_rule.contentValues()
# there is one delivery line - so one simulation movement
self.assertEqual(1, len(simulation_movement_list))
simulation_movement = simulation_movement_list[0]
# now check if simulation movement has all properties set correctly
self.assertEqual( self.expected_resource, simulation_movement.getResourceValue())
self.assertEqual( self.expected_quantity, simulation_movement.getQuantity())
self.assertEqual( self.expected_source, simulation_movement.getSourceValue())
self.assertEqual( self.expected_source_section, simulation_movement.getSourceSectionValue())
self.assertEqual( self.expected_destination, simulation_movement.getDestinationValue())
self.assertEqual( self.expected_destination_section,
simulation_movement.getDestinationSectionValue())
self.assertEqual( self.expected_start_date, simulation_movement.getStartDate())
self.assertEqual( self.expected_stop_date, simulation_movement.getStopDate()
)
def createDocuments(self):
self.resource = self.createResource()
self.source = self.createOrganisation()
self.source_section = self.createOrganisation()
self.destination = self.createOrganisation()
self.destination_section = self.createOrganisation()
self.delivery = self.createDelivery(
source_value = self.source,
source_section_value = self.source_section,
destination_value = self.destination,
destination_section_value = self.destination_section,
start_date = self.datetime,
stop_date = self.datetime,
)
self.delivery_line = self.delivery.newContent(
portal_type=self.delivery_line_portal_type)
self.delivery_line.edit(
resource_value = self.resource,
quantity = self.default_quantity
)
self.expected_resource = self.resource
self.expected_quantity = self.default_quantity
self.expected_start_date = self.datetime
self.expected_stop_date = self.datetime
self.expected_source = self.source
self.expected_source_section = self.source_section
self.expected_destination = self.destination
self.expected_destination_section = self.destination_section
def modifyDelivery(self, change_expected=True):
# for now only quantity
new_quantity = self.delivery_line.getQuantity() - 1
self.delivery_line.edit(quantity = new_quantity)
if change_expected:
self.expected_quantity = new_quantity
def test_rule_simulation_confirm(self):
self.createDocuments()
self.delivery.confirm()
self.assertEqual('confirmed', self.delivery.getSimulationState())
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
self.modifyDelivery()
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
def test_rule_simulation_ready(self):
self.createDocuments()
self.delivery.confirm()
self.delivery.setReady()
self.assertEqual('ready', self.delivery.getSimulationState())
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
self.modifyDelivery()
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
def test_rule_simulation_start(self):
self.createDocuments()
self.delivery.confirm()
self.delivery.setReady()
self.delivery.start()
self.assertEqual('started', self.delivery.getSimulationState())
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
self.modifyDelivery()
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
def test_rule_simulation_stop(self):
self.createDocuments()
self.delivery.confirm()
self.delivery.setReady()
self.delivery.start()
self.delivery.stop()
self.assertEqual('stopped', self.delivery.getSimulationState())
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
# stopped state freezes simulation
self.modifyDelivery(False)
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
def test_rule_simulation_deliver(self):
self.createDocuments()
self.delivery.confirm()
self.delivery.setReady()
self.delivery.start()
self.delivery.stop()
self.delivery.deliver()
self.assertEqual('delivered', self.delivery.getSimulationState())
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
# delivered state freezes simulation
self.modifyDelivery(False)
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
def test_rule_simulation_cancel(self):
self.createDocuments()
self.delivery.confirm()
self.assertEqual('confirmed', self.delivery.getSimulationState())
transaction.commit() ; self.tic()
self.delivery.cancel()
self.assertEqual('cancelled', self.delivery.getSimulationState())
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
# cancelled state freezes simulation
self.modifyDelivery(False)
transaction.commit() ; self.tic()
self.checkDeliverySimulation()
class TestDeliveryRuleSalePackingList(TestDeliveryRule):
delivery_portal_type = 'Sale Packing List'
delivery_line_portal_type = 'Sale Packing List Line'
rule_portal_type = 'Delivery Rule'
def getTitle(self):
return "Sale Packing List Delivery Rule"
class TestDeliveryRulePurchasePackingList(TestDeliveryRule):
delivery_portal_type = 'Purchase Packing List'
delivery_line_portal_type = 'Purchase Packing List Line'
rule_portal_type = 'Delivery Rule'
def getTitle(self):
return "Purchase Packing List Delivery Rule"
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPackingList)) suite.addTest(unittest.makeSuite(TestPackingList))
suite.addTest(unittest.makeSuite(TestPurchasePackingList)) suite.addTest(unittest.makeSuite(TestPurchasePackingList))
suite.addTest(unittest.makeSuite(TestDeliveryRuleSalePackingList))
suite.addTest(unittest.makeSuite(TestDeliveryRulePurchasePackingList))
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