Commit d4d1c020 authored by Jérome Perrin's avatar Jérome Perrin

testOrder: really test getVariationCategoryItemList and getVariationCategoryList

basically, rewrite :
self.assertEqual(result_of_complex_method, result_of_another_complex_method)
into:
self.assertEqual(expected_value, result_of_another_complex_method)
parent 3d83868c
...@@ -566,19 +566,6 @@ class TestOrderMixin(SubcontentReindexingWrapper): ...@@ -566,19 +566,6 @@ class TestOrderMixin(SubcontentReindexingWrapper):
vrcil = order_line.getVariationRangeCategoryItemList() vrcil = order_line.getVariationRangeCategoryItemList()
self.failIfDifferentSet(vrcl, map(lambda x: x[1], vrcil)) self.failIfDifferentSet(vrcl, map(lambda x: x[1], vrcil))
def stepCheckOrderLineVCIL(self, sequence=None, sequence_list=None, **kw):
"""
Check if getVariationCategoryItemList returns the good result.
Does not test display...
Item are left display.
"""
order_line = sequence.get('order_line')
vcl = order_line.getVariationCategoryList()
vcil = order_line.getVariationCategoryItemList()
LOG('stepCheckOrderLineVCIL', 0, 'vcl: %s\n' % str(vcl))
LOG('stepCheckOrderLineVCIL', 0, 'vcil: %s\n' % str(vcil))
self.failIfDifferentSet(vcl, map(lambda x: x[1], vcil))
def stepSetOrderLineDefaultValues(self, sequence=None, \ def stepSetOrderLineDefaultValues(self, sequence=None, \
sequence_list=None, **kw): sequence_list=None, **kw):
""" """
...@@ -1356,34 +1343,79 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase): ...@@ -1356,34 +1343,79 @@ class TestOrder(TestOrderMixin, ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def test_03_OrderLine_getVariationCategoryList(self, quiet=0, def test_OrderLine_getVariationCategoryList(self):
run=run_all_test): order_module = self.portal.getDefaultModule(portal_type=self.order_portal_type)
""" order = order_module.newContent(portal_type=self.order_portal_type,
Test order line getVariationCategoryList. specialise=self.business_process)
Not yet tested....
"""
if not run: return
def test_04_OrderLine_getVariationCategoryItemList(self, quiet=0, resource_module = self.portal.getDefaultModule(self.resource_portal_type)
run=run_all_test): resource = resource_module.newContent(portal_type=self.resource_portal_type)
""" resource.edit(
Test order line getVariationCategoryItemList. industrial_phase_list=["phase1", "phase2"],
""" size_list=['Baby', 'Woman']
if not run: return )
sequence_list = SequenceList() order_line = order.newContent(
# Test when resource has variation portal_type=self.order_line_portal_type,
sequence_string = 'stepCreateOrder \ resource_value=resource)
stepCreateOrderLine \
stepCheckOrderLineVCIL \ order_line.setVariationCategoryList(['size/Baby'])
stepCreateVariatedResource \ self.assertEqual(['size/Baby'], order_line.getVariationCategoryList())
stepTic \ self.assertEqual(sorted(['size']),
stepSetOrderLineResource \ sorted(order_line.getVariationBaseCategoryList()))
stepSetOrderLineHalfVCL \
stepTic \ order_line.setVariationCategoryList(['size/Baby', 'industrial_phase/phase1'])
stepCheckOrderLineVCIL \ self.assertEqual(sorted(['size/Baby', 'industrial_phase/phase1']),
' sorted(order_line.getVariationCategoryList()))
sequence_list.addSequenceString(sequence_string) self.assertEqual(sorted(['industrial_phase', 'size']),
sequence_list.play(self) sorted(order_line.getVariationBaseCategoryList()))
self.assertEqual(['size/Baby'],
order_line.getVariationCategoryList(base_category_list=('size',)))
self.assertEqual([],
order_line.getVariationCategoryList(base_category_list=('other',)))
def test_OrderLine_getVariationCategoryItemList(self):
order_module = self.portal.getDefaultModule(portal_type=self.order_portal_type)
order = order_module.newContent(portal_type=self.order_portal_type,
specialise=self.business_process)
resource_module = self.portal.getDefaultModule(self.resource_portal_type)
resource = resource_module.newContent(portal_type=self.resource_portal_type)
resource.edit(
industrial_phase_list=["phase1", "phase2"],
size_list=['Baby', 'Woman']
)
self.assertEqual(sorted([
['Industrial Phase/phase1', 'industrial_phase/phase1'],
['Industrial Phase/phase2', 'industrial_phase/phase2'],
['Size/Baby', 'size/Baby'],
['Size/Woman', 'size/Woman'], ]),
sorted(resource.getVariationCategoryItemList()))
order_line = order.newContent(
portal_type=self.order_line_portal_type,
resource_value=resource)
order_line.setVariationCategoryList(['size/Baby'])
self.assertEqual(
[['Baby', 'size/Baby']],
order_line.getVariationCategoryItemList())
self.assertEqual(sorted(['size']),
sorted(order_line.getVariationBaseCategoryList()))
order_line.setVariationCategoryList(['size/Baby', 'industrial_phase/phase1'])
self.assertEqual(sorted([
['Baby', 'size/Baby'],
['phase1', 'industrial_phase/phase1'], ]),
sorted(order_line.getVariationCategoryItemList()))
self.assertEqual(sorted(['size', 'industrial_phase']),
sorted(order_line.getVariationBaseCategoryList()))
self.assertEqual([['Baby', 'size/Baby']],
order_line.getVariationCategoryItemList(base_category_list=('size',)))
self.assertEqual([],
order_line.getVariationCategoryItemList(base_category_list=('other',)))
def test_05_OrderLine_Matrix(self, quiet=0, run=run_all_test): def test_05_OrderLine_Matrix(self, quiet=0, run=run_all_test):
""" """
......
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