Commit 07dedbdd authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: erp5_trade: Migrate Unit Tests.

parent c7c2ad83
...@@ -79,7 +79,7 @@ class TestAmount(ERP5TypeTestCase): ...@@ -79,7 +79,7 @@ class TestAmount(ERP5TypeTestCase):
""" """
return 1 return 1
def afterSetUp(self, quiet=1, run=run_all_test): def afterSetUp(self, *args, **kw):
self.login() self.login()
def stepCreateResource(self, sequence=None, sequence_list=None, **kw): def stepCreateResource(self, sequence=None, sequence_list=None, **kw):
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testAmount</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testAmount</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testAmount</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -70,7 +70,7 @@ class TestResource(ERP5TypeTestCase): ...@@ -70,7 +70,7 @@ class TestResource(ERP5TypeTestCase):
def getTitle(self): def getTitle(self):
return "Resource" return "Resource"
def login(self): def login(self, *args, **kw):
uf = self.getPortal().acl_users uf = self.getPortal().acl_users
uf._doAddUser('rc', '', ['Manager'], []) uf._doAddUser('rc', '', ['Manager'], [])
user = uf.getUserById('rc').__of__(uf) user = uf.getUserById('rc').__of__(uf)
...@@ -122,28 +122,25 @@ class TestResource(ERP5TypeTestCase): ...@@ -122,28 +122,25 @@ class TestResource(ERP5TypeTestCase):
size_category_list = ['Baby', 'Child', 'Man', 'Woman'] size_category_list = ['Baby', 'Child', 'Man', 'Woman']
if len(self.category_tool.size.contentValues()) == 0 : if len(self.category_tool.size.contentValues()) == 0 :
for category_id in size_category_list: for category_id in size_category_list:
o = self.category_tool.size.newContent(portal_type='Category', self.category_tool.size.newContent(portal_type='Category',
id=category_id) id=category_id)
self.size_category_list = map(lambda x: 'size/%s' % x, self.size_category_list = ['size/%s' % x for x in size_category_list]
size_category_list)
colour_category_list = ['blue', 'green'] colour_category_list = ['blue', 'green']
if len(self.category_tool.colour.contentValues()) == 0 : if len(self.category_tool.colour.contentValues()) == 0 :
for category_id in colour_category_list: for category_id in colour_category_list:
o = self.category_tool.colour.newContent(portal_type='Category', self.category_tool.colour.newContent(portal_type='Category',
id=category_id) id=category_id)
self.colour_category_list = map(lambda x: 'colour/%s' % x, self.colour_category_list = ['colour/%s' % x for x in colour_category_list]
colour_category_list)
ind_phase_category_list = ['phase1', 'phase2'] ind_phase_category_list = ['phase1', 'phase2']
if len(self.category_tool.industrial_phase.contentValues()) == 0: if len(self.category_tool.industrial_phase.contentValues()) == 0:
for category_id in ind_phase_category_list: for category_id in ind_phase_category_list:
o = self.category_tool.industrial_phase.newContent( self.category_tool.industrial_phase.newContent(
portal_type='Category', portal_type='Category',
id=category_id) id=category_id)
self.industrial_phase_category_list = map( self.industrial_phase_category_list = [
lambda x: 'industrial_phase/%s' % x, 'industrial_phase/%s' % x for x in ind_phase_category_list]
ind_phase_category_list)
self.morphology_category_list = [] self.morphology_category_list = []
self.base_category_content_list = { self.base_category_content_list = {
...@@ -251,7 +248,7 @@ class TestResource(ERP5TypeTestCase): ...@@ -251,7 +248,7 @@ class TestResource(ERP5TypeTestCase):
Set category variation to current resource Set category variation to current resource
""" """
resource = sequence.get('resource') resource = sequence.get('resource')
size_list = map(lambda x: x[len('size/'):], self.size_list) size_list = [x[len('size/'):] for x in self.size_list]
resource.setSizeList(size_list) resource.setSizeList(size_list)
self.category_list = self.size_list[:] self.category_list = self.size_list[:]
...@@ -373,7 +370,7 @@ class TestResource(ERP5TypeTestCase): ...@@ -373,7 +370,7 @@ class TestResource(ERP5TypeTestCase):
resource = sequence.get('resource') resource = sequence.get('resource')
vrcl = resource.getVariationRangeCategoryList() vrcl = resource.getVariationRangeCategoryList()
vrcil = resource.getVariationRangeCategoryItemList() vrcil = resource.getVariationRangeCategoryItemList()
self.failIfDifferentSet(vrcl, map(lambda x: x[1], vrcil)) self.failIfDifferentSet(vrcl, [x[1] for x in vrcil])
def test_03_getVariationRangeCategoryItemList(self, quiet=quiet, def test_03_getVariationRangeCategoryItemList(self, quiet=quiet,
run=run_all_test): run=run_all_test):
...@@ -434,7 +431,7 @@ class TestResource(ERP5TypeTestCase): ...@@ -434,7 +431,7 @@ class TestResource(ERP5TypeTestCase):
resource = sequence.get('resource') resource = sequence.get('resource')
vcl = resource.getVariationCategoryList() vcl = resource.getVariationCategoryList()
vcil = resource.getVariationCategoryItemList() vcil = resource.getVariationCategoryItemList()
self.failIfDifferentSet(vcl, map(lambda x: x[1], vcil)) self.failIfDifferentSet(vcl, [x[1] for x in vcil])
def test_06_getVariationCategoryItemList(self, quiet=quiet, run=run_all_test): def test_06_getVariationCategoryItemList(self, quiet=quiet, run=run_all_test):
""" """
...@@ -452,7 +449,7 @@ class TestResource(ERP5TypeTestCase): ...@@ -452,7 +449,7 @@ class TestResource(ERP5TypeTestCase):
resource = sequence.get('resource') resource = sequence.get('resource')
vcl = resource.getVariationCategoryList(omit_individual_variation=0) vcl = resource.getVariationCategoryList(omit_individual_variation=0)
vcil = resource.getVariationCategoryItemList(omit_individual_variation=0) vcil = resource.getVariationCategoryItemList(omit_individual_variation=0)
self.failIfDifferentSet(vcl, map(lambda x: x[1], vcil)) self.failIfDifferentSet(vcl, [x[1] for x in vcil])
def test_07_getVariationCategoryItemList(self, quiet=quiet, run=run_all_test): def test_07_getVariationCategoryItemList(self, quiet=quiet, run=run_all_test):
""" """
...@@ -581,7 +578,7 @@ class TestResource(ERP5TypeTestCase): ...@@ -581,7 +578,7 @@ class TestResource(ERP5TypeTestCase):
] ]
return config return config
def logMessage(self, msg, tab=0): def logMessage(self, msg, tab=0): # pylint: disable=arguments-differ
""" """
Log a message. Log a message.
""" """
...@@ -611,7 +608,7 @@ class TestResource(ERP5TypeTestCase): ...@@ -611,7 +608,7 @@ class TestResource(ERP5TypeTestCase):
for key, value in config.items(): for key, value in config.items():
if key != 'price': if key != 'price':
if value not in [None, []]: if value not in [None, []]:
if type(value) != type([]): if not isinstance(value, list):
value_list = [value] value_list = [value]
else: else:
value_list = value value_list = value
...@@ -918,7 +915,6 @@ class TestResource(ERP5TypeTestCase): ...@@ -918,7 +915,6 @@ class TestResource(ERP5TypeTestCase):
# Initialize variables # Initialize variables
product_module = self.portal.getDefaultModule(self.product_portal_type) product_module = self.portal.getDefaultModule(self.product_portal_type)
organisation_module = self.getOrganisationModule() organisation_module = self.getOrganisationModule()
currency_module = self.getCurrencyModule()
sale_order_module = self.portal.getDefaultModule("Sale Order") sale_order_module = self.portal.getDefaultModule("Sale Order")
purchase_order_module = self.portal.getDefaultModule("Purchase Order") purchase_order_module = self.portal.getDefaultModule("Purchase Order")
internal_packing_list_module = self.portal.getDefaultModule("Internal Packing List") internal_packing_list_module = self.portal.getDefaultModule("Internal Packing List")
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testResource</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testResource</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testResource</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -33,7 +33,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase ...@@ -33,7 +33,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import reindex from Products.ERP5Type.tests.utils import reindex
from Products.ERP5Type.tests.utils import SubcontentReindexingWrapper from Products.ERP5Type.tests.utils import SubcontentReindexingWrapper
from DateTime import DateTime from DateTime import DateTime
import transaction
class TestSupplyMixin: class TestSupplyMixin:
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSupply</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testSupply</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSupply</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testAmount
test.erp5.testDeliveryNode test.erp5.testDeliveryNode
test.erp5.testDivergenceTester test.erp5.testDivergenceTester
test.erp5.testERP5Simulation test.erp5.testERP5Simulation
...@@ -10,6 +11,8 @@ test.erp5.testOrderBuilder ...@@ -10,6 +11,8 @@ test.erp5.testOrderBuilder
test.erp5.testPackingList test.erp5.testPackingList
test.erp5.testPackingListRoundingPrecision test.erp5.testPackingListRoundingPrecision
test.erp5.testPurchaseOrder test.erp5.testPurchaseOrder
test.erp5.testResource
test.erp5.testReturnedOrder test.erp5.testReturnedOrder
test.erp5.testReturnedSalePackingList test.erp5.testReturnedSalePackingList
test.erp5.testSupply
test.erp5.testTradeReports test.erp5.testTradeReports
\ No newline at end of file
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