Commit 5175279f authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add more tests.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@944 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c98334fd
...@@ -64,7 +64,7 @@ class TestFusion(ERP5TypeTestCase): ...@@ -64,7 +64,7 @@ class TestFusion(ERP5TypeTestCase):
- livraison_fabrication (Production Packing List) - livraison_fabrication (Production Packing List)
- rapport_fabrication (Production Report) - rapport_fabrication (Production Report)
""" """
run_all_test = 1 run_all_test = 0
# Various variables used for this test # Various variables used for this test
customer_organisation_id = 'nexedi' customer_organisation_id = 'nexedi'
customer_person_id = 'yo' customer_person_id = 'yo'
...@@ -101,11 +101,29 @@ class TestFusion(ERP5TypeTestCase): ...@@ -101,11 +101,29 @@ class TestFusion(ERP5TypeTestCase):
def getOrganisationModule(self): def getOrganisationModule(self):
return getattr(self.getPortal(), 'organisation', None) return getattr(self.getPortal(), 'organisation', None)
def getSalesOrderModule(self):
return getattr(self.getPortal(), 'commande_vente', None)
def getSalesPackingListModule(self): def getSalesPackingListModule(self):
return getattr(self.getPortal(), 'livraison_vente', None) return getattr(self.getPortal(), 'livraison_vente', None)
def getSalesOrderModule(self): def getSaleInvoiceModule(self):
return getattr(self.getPortal(), 'commande_vente', None) return getattr(self.getPortal(), 'facture_vente', None)
def getPurchaseOrderModule(self):
return getattr(self.getPortal(), 'commande_achat', None)
def getPurchasePackingListModule(self):
return getattr(self.getPortal(), 'livraison_achat', None)
def getProductionOrderModule(self):
return getattr(self.getPortal(), 'ordre_fabrication', None)
def getProductionPackingListModule(self):
return getattr(self.getPortal(), 'livraison_fabrication', None)
def getProductionReportModule(self):
return getattr(self.getPortal(), 'rapport_fabrication', None)
def afterSetUp(self, quiet=1, run=1): def afterSetUp(self, quiet=1, run=1):
self.login() self.login()
...@@ -116,6 +134,10 @@ class TestFusion(ERP5TypeTestCase): ...@@ -116,6 +134,10 @@ class TestFusion(ERP5TypeTestCase):
portal.portal_categories.immediateReindexObject() portal.portal_categories.immediateReindexObject()
for o in portal.portal_categories.objectValues(): for o in portal.portal_categories.objectValues():
o.recursiveImmediateReindexObject() o.recursiveImmediateReindexObject()
portal.portal_simulation.immediateReindexObject()
for o in portal.portal_simulation.objectValues():
o.recursiveImmediateReindexObject()
portal.portal_rules.immediateReindexObject()
# Create organisations. # Create organisations.
portal.portal_types.constructContent(type_name='Organisation Module', portal.portal_types.constructContent(type_name='Organisation Module',
container=portal, container=portal,
...@@ -258,6 +280,7 @@ class TestFusion(ERP5TypeTestCase): ...@@ -258,6 +280,7 @@ class TestFusion(ERP5TypeTestCase):
def setCell(self, line, category_list, **kw): def setCell(self, line, category_list, **kw):
category_list = list(category_list) category_list = list(category_list)
category_list.sort() category_list.sort()
LOG('setCell', 0, 'line = %s, line.contentValues() = %s, line.objectIds() = %s' % (repr(line), repr(line.contentValues()), repr(list(line.objectIds()))))
for cell in line.contentValues(): for cell in line.contentValues():
predicate_value_list = cell.getPredicateValueList() predicate_value_list = cell.getPredicateValueList()
predicate_value_list.sort() predicate_value_list.sort()
...@@ -265,98 +288,101 @@ class TestFusion(ERP5TypeTestCase): ...@@ -265,98 +288,101 @@ class TestFusion(ERP5TypeTestCase):
cell.edit(**kw) cell.edit(**kw)
return cell return cell
def makeSalesPackingLists(self): def makeDeliveries(self, module, delivery_type, delivery_line_type):
module = self.getSalesPackingListModule()
for id in ('1', '2', '3'): for id in ('1', '2', '3'):
if module.hasContent(id): if module.hasContent(id):
module.deleteContent(id) module.deleteContent(id)
pl1 = module.newContent(id='1', portal_type='Sales Packing List') d1 = module.newContent(id='1', portal_type=delivery_type)
pl1_line1 = pl1.newContent(id='1', portal_type='Sales Packing List Line', d1_line1 = d1.newContent(id='1', portal_type=delivery_line_type,
resource='modele/004C401', resource='modele/004C401',
price=2.0, price=2.0,
quantity=1.0, quantity=1.0,
target_quantity=1.0) target_quantity=1.0)
pl1_line2 = pl1.newContent(id='2', portal_type='Sales Packing List Line', d1_line2 = d1.newContent(id='2', portal_type=delivery_line_type,
resource='modele/060E404', resource='modele/060E404',
variation_base_category_list = ['morphologie', 'taille', 'coloris'], variation_base_category_list = ['morphologie', 'taille', 'coloris'],
variation_category_list = ['morphologie/modele/060E404/C', 'morphologie/modele/060E404/B', 'taille/adulte/38', 'taille/adulte/40', 'taille/adulte/42', 'coloris/modele/060E404/Violet_rose', 'coloris/modele/060E404/noir_gris']) variation_category_list = ['morphologie/modele/060E404/C', 'morphologie/modele/060E404/B', 'taille/adulte/38', 'taille/adulte/40', 'taille/adulte/42', 'coloris/modele/060E404/Violet_rose', 'coloris/modele/060E404/noir_gris'])
cell = self.setCell(pl1_line2, cell = self.setCell(d1_line2,
('coloris/modele/060E404/Violet_rose', 'morphologie/modele/060E404/C', 'taille/adulte/38'), ('coloris/modele/060E404/Violet_rose', 'morphologie/modele/060E404/C', 'taille/adulte/38'),
price = 5.0, price = 5.0,
quantity = 1.0, quantity = 1.0,
target_quantity = 1.0) target_quantity = 1.0)
self.assertNotEqual(cell, None) self.assertNotEqual(cell, None)
cell = self.setCell(pl1_line2, cell = self.setCell(d1_line2,
('coloris/modele/060E404/noir_gris', 'morphologie/modele/060E404/C', 'taille/adulte/40'), ('coloris/modele/060E404/noir_gris', 'morphologie/modele/060E404/C', 'taille/adulte/40'),
price = 5.0, price = 5.0,
quantity = 2.0, quantity = 2.0,
target_quantity = 2.0) target_quantity = 2.0)
self.assertNotEqual(cell, None) self.assertNotEqual(cell, None)
pl1_line2.recursiveImmediateReindexObject() d1_line2.recursiveImmediateReindexObject()
self.assertAlmostEqual(pl1_line2.getTotalPrice(), 5.0 * (1.0 + 2.0)) self.assertAlmostEqual(d1_line2.getTotalPrice(), 5.0 * (1.0 + 2.0))
self.assertAlmostEqual(pl1_line2.getTotalQuantity(), 1.0 + 2.0) self.assertAlmostEqual(d1_line2.getTotalQuantity(), 1.0 + 2.0)
pl1_line3 = pl1.newContent(id='3', portal_type='Sales Packing List Line', d1_line3 = d1.newContent(id='3', portal_type=delivery_line_type,
resource='modele/060E404', resource='modele/060E404',
price=0.0, price=0.0,
variation_base_category_list = ['taille', 'coloris'], variation_base_category_list = ['taille', 'coloris'],
variation_category_list = ['coloris/modele/060E404/Violet_rose', 'taille/adulte/38', 'taille/adulte/40', 'taille/adulte/42', 'coloris/modele/060E404/noir_gris']) variation_category_list = ['coloris/modele/060E404/Violet_rose', 'taille/adulte/38', 'taille/adulte/40', 'taille/adulte/42', 'coloris/modele/060E404/noir_gris'])
cell = self.setCell(pl1_line3, cell = self.setCell(d1_line3,
('coloris/modele/060E404/Violet_rose', 'taille/adulte/40'), ('coloris/modele/060E404/Violet_rose', 'taille/adulte/40'),
price = 3.0, price = 3.0,
quantity = 3.0, quantity = 3.0,
target_quantity = 3.0) target_quantity = 3.0)
self.assertNotEqual(cell, None) self.assertNotEqual(cell, None)
cell = self.setCell(pl1_line3, cell = self.setCell(d1_line3,
('coloris/modele/060E404/noir_gris', 'taille/adulte/42'), ('coloris/modele/060E404/noir_gris', 'taille/adulte/42'),
price = 4.0, price = 4.0,
quantity = 5.0, quantity = 5.0,
target_quantity = 5.0) target_quantity = 5.0)
self.assertNotEqual(cell, None) self.assertNotEqual(cell, None)
pl1.recursiveImmediateReindexObject() d1.recursiveImmediateReindexObject()
LOG('testFusion _makeDeliveries', 0, 'cell = %s, cell.getVariationCategoryList() = %s, cell.showDict() = %s' % (repr(cell), str(cell.getVariationCategoryList()), repr(cell.showDict())))
pl2 = module.newContent(id='2', portal_type='Sales Packing List') d2 = module.newContent(id='2', portal_type=delivery_type)
pl2_line1 = pl2.newContent(id='1', portal_type='Sales Packing List Line', d2_line1 = d2.newContent(id='1', portal_type=delivery_line_type,
resource='modele/004C401', resource='modele/004C401',
price=7.0, price=7.0,
quantity=2.0, quantity=2.0,
target_quantity=2.0) target_quantity=2.0)
pl2_line2 = pl2.newContent(id='2', portal_type='Sales Packing List Line', d2_line2 = d2.newContent(id='2', portal_type=delivery_line_type,
resource='modele/060E404', resource='modele/060E404',
variation_base_category_list = ['morphologie', 'taille', 'coloris'], variation_base_category_list = ['morphologie', 'taille', 'coloris'],
variation_category_list = ['morphologie/modele/060E404/C', 'morphologie/modele/060E404/B', 'taille/adulte/36', 'taille/adulte/38', 'taille/adulte/40', 'coloris/modele/060E404/Violet_rose', 'coloris/modele/060E404/noir_gris']) variation_category_list = ['morphologie/modele/060E404/C', 'morphologie/modele/060E404/B', 'taille/adulte/36', 'taille/adulte/38', 'taille/adulte/40', 'coloris/modele/060E404/Violet_rose', 'coloris/modele/060E404/noir_gris'])
cell = self.setCell(pl2_line2, cell = self.setCell(d2_line2,
('coloris/modele/060E404/Violet_rose', 'morphologie/modele/060E404/C', 'taille/adulte/36'), ('coloris/modele/060E404/Violet_rose', 'morphologie/modele/060E404/C', 'taille/adulte/36'),
price = 5.0, price = 5.0,
quantity = 1.0, quantity = 1.0,
target_quantity = 1.0) target_quantity = 1.0)
self.assertNotEqual(cell, None) self.assertNotEqual(cell, None)
cell = self.setCell(pl2_line2, cell = self.setCell(d2_line2,
('coloris/modele/060E404/noir_gris', 'morphologie/modele/060E404/C', 'taille/adulte/40'), ('coloris/modele/060E404/noir_gris', 'morphologie/modele/060E404/C', 'taille/adulte/40'),
price = 5.0, price = 5.0,
quantity = 2.0, quantity = 2.0,
target_quantity = 2.0) target_quantity = 2.0)
self.assertNotEqual(cell, None) self.assertNotEqual(cell, None)
pl2.recursiveImmediateReindexObject() d2_line2.recursiveImmediateReindexObject()
self.assertAlmostEqual(d2_line2.getTotalPrice(), 5.0 * (1.0 + 2.0))
self.assertAlmostEqual(d2_line2.getTotalQuantity(), 1.0 + 2.0)
d2.recursiveImmediateReindexObject()
pl3 = module.newContent(id='3', portal_type='Sales Packing List') d3 = module.newContent(id='3', portal_type=delivery_type)
pl3_line1 = pl3.newContent(id='1', portal_type='Sales Packing List Line', d3_line1 = d3.newContent(id='1', portal_type=delivery_line_type,
resource='modele/060E404', resource='modele/060E404',
variation_base_category_list = ['morphologie', 'taille', 'coloris'], variation_base_category_list = ['morphologie', 'taille', 'coloris'],
variation_category_list = ['morphologie/modele/060E404/C', 'morphologie/modele/060E404/B', 'taille/adulte/44', 'coloris/modele/060E404/Violet_rose', 'coloris/modele/060E404/noir_gris']) variation_category_list = ['morphologie/modele/060E404/C', 'morphologie/modele/060E404/B', 'taille/adulte/44', 'coloris/modele/060E404/Violet_rose', 'coloris/modele/060E404/noir_gris'])
cell = self.setCell(pl3_line1, cell = self.setCell(d3_line1,
('coloris/modele/060E404/Violet_rose', 'morphologie/modele/060E404/C', 'taille/adulte/44'), ('coloris/modele/060E404/Violet_rose', 'morphologie/modele/060E404/C', 'taille/adulte/44'),
price = 3.0, price = 3.0,
quantity = 3.0, quantity = 3.0,
target_quantity = 3.0) target_quantity = 3.0)
self.assertNotEqual(cell, None) self.assertNotEqual(cell, None)
pl3.recursiveImmediateReindexObject() d3.recursiveImmediateReindexObject()
def _testSalesPackingLists(self, pl1, pl2, pl3): def _checkDeliveries(self, d1, d2, d3):
self.assertEqual(len(pl1.objectIds()), 3) self.assertEqual(len(d1.objectIds()), 3)
self.assertEqual(pl2.getSimulationState(), 'cancelled') self.assertEqual(d2.getSimulationState(), 'cancelled')
self.assertEqual(pl3.getSimulationState(), 'cancelled') self.assertEqual(d3.getSimulationState(), 'cancelled')
line1 = line2 = line3 = None line1 = line2 = line3 = None
for line in pl1.contentValues(): for line in d1.contentValues():
if line.getResource() == 'modele/004C401': if line.getResource() == 'modele/004C401':
line1 = line line1 = line
elif line.getResource() == 'modele/060E404': elif line.getResource() == 'modele/060E404':
...@@ -364,6 +390,9 @@ class TestFusion(ERP5TypeTestCase): ...@@ -364,6 +390,9 @@ class TestFusion(ERP5TypeTestCase):
line2 = line line2 = line
else: else:
line3 = line line3 = line
LOG('_checkDeliveries', 0, 'line1 = %s, line1.objectIds() = %s' % (repr(line1), repr(list(line1.objectIds()))))
LOG('_checkDeliveries', 0, 'line2 = %s, line2.objectIds() = %s' % (repr(line2), repr(list(line2.objectIds()))))
LOG('_checkDeliveries', 0, 'line3 = %s, line3.objectIds() = %s' % (repr(line3), repr(list(line3.objectIds()))))
self.assertNotEqual(line1, None) self.assertNotEqual(line1, None)
self.assertAlmostEqual(line1.getTotalQuantity(), 1.0 + 2.0) self.assertAlmostEqual(line1.getTotalQuantity(), 1.0 + 2.0)
self.assertAlmostEqual(line1.getTotalPrice(), 2.0 * 1.0 + 7.0 * 2.0) self.assertAlmostEqual(line1.getTotalPrice(), 2.0 * 1.0 + 7.0 * 2.0)
...@@ -383,30 +412,65 @@ class TestFusion(ERP5TypeTestCase): ...@@ -383,30 +412,65 @@ class TestFusion(ERP5TypeTestCase):
self.assertEqual(category_list, ['coloris/modele/060E404/Violet_rose', 'coloris/modele/060E404/noir_gris', 'taille/adulte/38', 'taille/adulte/40', 'taille/adulte/42']) self.assertEqual(category_list, ['coloris/modele/060E404/Violet_rose', 'coloris/modele/060E404/noir_gris', 'taille/adulte/38', 'taille/adulte/40', 'taille/adulte/42'])
#self.assertAlmostEqual(line3.getPrice(), line3.getTotalPrice() / line3.getTotalQuantity()) #self.assertAlmostEqual(line3.getPrice(), line3.getTotalPrice() / line3.getTotalQuantity())
def test_03_SalesPackingLists(self, quiet=0, run=run_all_test): def _testDeliveries(self, module, delivery_type, delivery_line_type, quiet=0, run=run_all_test):
# Test mergeDeliveryList with Sales Packing Lists # Test mergeDeliveryList with Deliveries. This is shared among various deliveries.
if not run: return if not run: return
if not quiet: if not quiet:
message = '\nSales Packing Lists ' message = '\n%s ' % delivery_type
ZopeTestCase._print(message) ZopeTestCase._print(message)
LOG('Testing... ',0,message) LOG('Testing... ',0,message)
portal_simulation = self.getSimulationTool() portal_simulation = self.getSimulationTool()
module = self.getSalesPackingListModule()
self.makeSalesPackingLists() self.makeDeliveries(module, delivery_type, delivery_line_type)
pl = portal_simulation.mergeDeliveryList([module['1'], module['2'], module['3']]) pl = portal_simulation.mergeDeliveryList([module['1'], module['2'], module['3']])
pl.recursiveImmediateReindexObject() pl.recursiveImmediateReindexObject()
self._testSalesPackingLists(pl, module['2'], module['3']) self._checkDeliveries(module['1'], module['2'], module['3'])
self.makeSalesPackingLists() self.makeDeliveries(module, delivery_type, delivery_line_type)
pl = portal_simulation.mergeDeliveryList([module['2'], module['3'], module['1']]) pl = portal_simulation.mergeDeliveryList([module['2'], module['3'], module['1']])
pl.recursiveImmediateReindexObject() pl.recursiveImmediateReindexObject()
self._testSalesPackingLists(pl, module['3'], module['1']) self._checkDeliveries(module['2'], module['3'], module['1'])
self.makeSalesPackingLists() self.makeDeliveries(module, delivery_type, delivery_line_type)
pl = portal_simulation.mergeDeliveryList([module['3'], module['1'], module['2']]) pl = portal_simulation.mergeDeliveryList([module['3'], module['1'], module['2']])
pl.recursiveImmediateReindexObject() pl.recursiveImmediateReindexObject()
self._testSalesPackingLists(pl, module['1'], module['2']) self._checkDeliveries(module['3'], module['1'], module['2'])
#def test_03_SalesOrders(self, quiet=0, run=run_all_test):
def test_03_SalesOrders(self, quiet=0, run=1):
# Test mergeDeliveryList with Sales Orders
module = self.getSalesOrderModule()
self._testDeliveries(module, 'Sales Order', 'Sales Order Line', quiet=quiet, run=run)
def test_04_SalesPackingLists(self, quiet=0, run=run_all_test):
# Test mergeDeliveryList with Sales Packing Lists
module = self.getSalesPackingListModule()
self._testDeliveries(module, 'Sales Packing List', 'Sales Packing List Line', quiet=quiet, run=run)
def test_06_PurchaseOrders(self, quiet=0, run=run_all_test):
# Test mergeDeliveryList with Purchase Orders
module = self.getPurchaseOrderModule()
self._testDeliveries(module, 'Purchase Order', 'Purchase Order Line', quiet=quiet, run=run)
def test_07_PurchasePackingLists(self, quiet=0, run=run_all_test):
# Test mergeDeliveryList with Purchase Packing Lists
module = self.getPurchasePackingListModule()
self._testDeliveries(module, 'Purchase Packing List', 'Purchase Packing List Line', quiet=quiet, run=run)
def test_08_ProductionOrders(self, quiet=0, run=run_all_test):
# Test mergeDeliveryList with Production Orders
module = self.getProductionOrderModule()
self._testDeliveries(module, 'Production Order', 'Production Order Line', quiet=quiet, run=run)
def test_09_ProductionPackingLists(self, quiet=0, run=run_all_test):
# Test mergeDeliveryList with Production Packing Lists
module = self.getProductionPackingListModule()
self._testDeliveries(module, 'Production Packing List', 'Production Packing List Line', quiet=quiet, run=run)
def test_10_ProductionReports(self, quiet=0, run=run_all_test):
# Test mergeDeliveryList with Production Reports
module = self.getProductionReportModule()
self._testDeliveries(module, 'Production Report', 'Production Report Component', quiet=quiet, run=run)
if __name__ == '__main__': if __name__ == '__main__':
......
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