Commit e4f4e55e authored by Julien Muchembled's avatar Julien Muchembled

TestOrderBuilder: code style

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41628 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ff8b912c
...@@ -59,30 +59,21 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -59,30 +59,21 @@ class TestOrderBuilderMixin(TestOrderMixin):
max_delay = 0.0 max_delay = 0.0
min_flow = 0.0 min_flow = 0.0
def stepSetMaxDelayOnResource(self, sequence=None, sequence_list=None, def stepSetMaxDelayOnResource(self, sequence):
**kw):
""" """
Sets max_delay on resource Sets max_delay on resource
""" """
resource = sequence.get('resource') resource = sequence.get('resource')
resource.edit(max_delay=self.max_delay)
resource.edit( def stepSetMinFlowOnResource(self, sequence):
max_delay = self.max_delay,
)
def stepSetMinFlowOnResource(self, sequence=None, sequence_list=None,
**kw):
""" """
Sets min_flow on resource Sets min_flow on resource
""" """
resource = sequence.get('resource') resource = sequence.get('resource')
resource.edit(min_flow=self.min_flow)
resource.edit( def stepFillOrderBuilder(self, sequence):
min_flow = self.min_flow,
)
def stepFillOrderBuilder(self, sequence=None, sequence_list=None,
**kw):
""" """
Fills Order Builder with proper quantites Fills Order Builder with proper quantites
""" """
...@@ -94,9 +85,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -94,9 +85,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
delivery_portal_type = self.order_portal_type, delivery_portal_type = self.order_portal_type,
delivery_line_portal_type = self.order_line_portal_type, delivery_line_portal_type = self.order_line_portal_type,
delivery_cell_portal_type = self.order_cell_portal_type, delivery_cell_portal_type = self.order_cell_portal_type,
destination_value = organisation, destination_value = organisation,
resource_portal_type = self.resource_portal_type, resource_portal_type = self.resource_portal_type,
) )
...@@ -132,148 +121,67 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -132,148 +121,67 @@ class TestOrderBuilderMixin(TestOrderMixin):
int_index=1 int_index=1
) )
def stepCheckGeneratedDocumentListVariated(self, sequence=None, sequence_list=None, def stepCheckGeneratedDocumentListVariated(self, sequence):
**kw):
""" """
Checks documents generated by Order Builders with its properties for variated resource Checks documents generated by Order Builders with its properties for variated resource
""" """
# XXX: Some values still hardcoded
organisation = sequence.get('organisation') organisation = sequence.get('organisation')
resource = sequence.get('resource') resource = sequence.get('resource')
generated_document_list = sequence.get('generated_document_list') # XXX: add support for more generated documents
order, = sequence.get('generated_document_list')
self.assertEquals( self.assertEqual(order.getDestinationValue(), organisation)
1, # XXX self.assertEqual(order.getStartDate(), self.wanted_start_date)
len(generated_document_list) self.assertEqual(order.getStopDate(), self.wanted_stop_date)
)
# XXX: ... and for more lines/cells too
order = generated_document_list[0] order_line, = order.contentValues(portal_type=self.order_line_portal_type)
self.assertEqual(order_line.getResourceValue(), resource)
self.assertEquals( self.assertEqual(order_line.getTotalQuantity(),
order.getDestinationValue(), sum(self.wanted_quantity_matrix.itervalues()))
organisation
) quantity_matrix = {}
for cell in order_line.contentValues(portal_type=self.order_cell_portal_type):
self.assertEquals( key = cell.getProperty('membership_criterion_category')
order.getStartDate(), self.assertFalse(key in quantity_matrix)
self.wanted_start_date quantity_matrix[key] = cell.getQuantity()
) self.assertEqual(quantity_matrix, self.wanted_quantity_matrix)
self.assertEquals( def stepCheckGeneratedDocumentList(self, sequence):
order.getStopDate(),
self.wanted_stop_date
)
order_line_list = order.contentValues(filter={'portal_type':self.order_line_portal_type})
self.assertEquals(
1, # XXX
len(order_line_list)
)
order_line = order_line_list[0] # XXX: add support for more lines and cells too
self.assertEquals(
order_line.getResourceValue(),
resource
)
self.assertEquals(
order_line.getTotalQuantity(),
sum(self.wanted_quantity_matrix.itervalues())
)
order_cell_list = order_line.contentValues(filter={'portal_type':self.order_cell_portal_type})
self.assertEquals(
len(order_cell_list),
len(self.wanted_quantity_matrix.values())
)
for order_cell in order_cell_list:
self.assertEquals(
order_cell.getQuantity(),
self.wanted_quantity_matrix[
order_cell.getProperty('membership_criterion_category')
]
)
def stepCheckGeneratedDocumentList(self, sequence=None, sequence_list=None,
**kw):
""" """
Checks documents generated by Order Builders with its properties Checks documents generated by Order Builders with its properties
""" """
# XXX: Some values still hardcoded
organisation = sequence.get('organisation') organisation = sequence.get('organisation')
resource = sequence.get('resource') resource = sequence.get('resource')
generated_document_list = sequence.get('generated_document_list') # XXX: add support for more generated documents
order, = sequence.get('generated_document_list')
self.assertEquals( self.assertEqual(order.getDestinationValue(), organisation)
1, # XXX self.assertEqual(order.getStartDate(), self.wanted_start_date)
len(generated_document_list) self.assertEqual(order.getStopDate(), self.wanted_stop_date)
)
order = generated_document_list[0]
self.assertEquals(
order.getDestinationValue(),
organisation
)
self.assertEquals(
order.getStartDate(),
self.wanted_start_date
)
self.assertEquals( # XXX: ... and for more lines/cells too
order.getStopDate(), order_line, = order.contentValues(portal_type=self.order_line_portal_type)
self.wanted_stop_date self.assertEqual(order_line.getResourceValue(), resource)
) self.assertEqual(order_line.getTotalQuantity(), self.wanted_quantity)
order_line_list = order.contentValues(filter={'portal_type':self.order_line_portal_type}) def stepBuildOrderBuilder(self, sequence):
self.assertEquals(
1, # XXX
len(order_line_list)
)
order_line = order_line_list[0] # XXX: add support for more lines and cells too
self.assertEquals(
order_line.getResourceValue(),
resource
)
self.assertEquals(
order_line.getTotalQuantity(),
self.wanted_quantity
)
def stepBuildOrderBuilder(self, sequence=None, sequence_list=None,
**kw):
""" """
Invokes build method for Order Builder Invokes build method for Order Builder
""" """
order_builder = sequence.get('order_builder') order_builder = sequence.get('order_builder')
generated_document_list = order_builder.build() generated_document_list = order_builder.build()
sequence.edit(generated_document_list = generated_document_list) sequence.set('generated_document_list', generated_document_list)
def stepCreateOrderBuilder(self, sequence=None, sequence_list=None, def stepCreateOrderBuilder(self, sequence):
**kw):
""" """
Creates empty Order Builder Creates empty Order Builder
""" """
portal_orders = self.portal.portal_orders order_builder = self.portal.portal_orders.newContent(
portal_type=self.order_builder_portal_type)
order_builder = portal_orders.newContent( sequence.set('order_builder', order_builder)
portal_type = self.order_builder_portal_type
)
sequence.edit(
order_builder = order_builder
)
def stepDecreaseOrganisationResourceQuantityVariated(self, sequence=None, sequence_list=None, def stepDecreaseOrganisationResourceQuantityVariated(self, sequence):
**kw):
""" """
Creates movement with variation from organisation to None. Creates movement with variation from organisation to None.
Using Internal Packing List, confirms it. Using Internal Packing List, confirms it.
...@@ -300,7 +208,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -300,7 +208,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
) )
packing_list_line.setVariationCategoryList( packing_list_line.setVariationCategoryList(
list(self.decrease_quantity_matrix.iterkeys()) self.decrease_quantity_matrix.keys(),
) )
transaction.commit() transaction.commit()
...@@ -311,7 +219,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -311,7 +219,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
cell_key_list.sort() cell_key_list.sort()
for cell_key in cell_key_list: for cell_key in cell_key_list:
cell = packing_list_line.newCell(base_id=base_id, \ cell = packing_list_line.newCell(base_id=base_id,
portal_type=self.packing_list_cell_portal_type, *cell_key) portal_type=self.packing_list_cell_portal_type, *cell_key)
cell.edit(mapped_value_property_list=['price','quantity'], cell.edit(mapped_value_property_list=['price','quantity'],
quantity=self.decrease_quantity_matrix[cell_key[0]], quantity=self.decrease_quantity_matrix[cell_key[0]],
...@@ -320,8 +228,7 @@ class TestOrderBuilderMixin(TestOrderMixin): ...@@ -320,8 +228,7 @@ class TestOrderBuilderMixin(TestOrderMixin):
packing_list.confirm() packing_list.confirm()
def stepDecreaseOrganisationResourceQuantity(self, sequence=None, sequence_list=None, def stepDecreaseOrganisationResourceQuantity(self, sequence):
**kw):
""" """
Creates movement from organisation to None. Creates movement from organisation to None.
Using Internal Packing List, confirms it. Using Internal Packing List, confirms it.
...@@ -355,21 +262,21 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -355,21 +262,21 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
""" """
run_all_test = 1 run_all_test = 1
common_sequence_string = '\ common_sequence_string = """
CreateOrganisation \ CreateOrganisation
CreateNotVariatedResource \ CreateNotVariatedResource
SetMaxDelayOnResource \ SetMaxDelayOnResource
SetMinFlowOnResource \ SetMinFlowOnResource
Tic \ Tic
DecreaseOrganisationResourceQuantity \ DecreaseOrganisationResourceQuantity
Tic \ Tic
CreateOrderBuilder \ CreateOrderBuilder
FillOrderBuilder \ FillOrderBuilder
Tic \ Tic
BuildOrderBuilder \ BuildOrderBuilder
Tic \ Tic
CheckGeneratedDocumentList \ CheckGeneratedDocumentList
' """
def getTitle(self): def getTitle(self):
return "Order Builder" return "Order Builder"
...@@ -383,7 +290,7 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -383,7 +290,7 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
self.wanted_quantity = 1.0 self.wanted_quantity = 1.0
self.wanted_start_date = DateTime( self.wanted_start_date = DateTime(
str(self.datetime.earliestTime() \ str(self.datetime.earliestTime()
+ self.order_builder_hardcoded_time_diff)) + self.order_builder_hardcoded_time_diff))
self.wanted_stop_date = self.wanted_start_date self.wanted_stop_date = self.wanted_start_date
...@@ -399,25 +306,25 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -399,25 +306,25 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
""" """
if not run: return if not run: return
sequence_string = '\ sequence_string = """
CreateOrganisation \ CreateOrganisation
CreateVariatedResource \ CreateVariatedResource
SetMaxDelayOnResource \ SetMaxDelayOnResource
SetMinFlowOnResource \ SetMinFlowOnResource
Tic \ Tic
DecreaseOrganisationResourceQuantityVariated \ DecreaseOrganisationResourceQuantityVariated
Tic \ Tic
CreateOrderBuilder \ CreateOrderBuilder
FillOrderBuilder \ FillOrderBuilder
Tic \ Tic
BuildOrderBuilder \ BuildOrderBuilder
Tic \ Tic
CheckGeneratedDocumentListVariated \ CheckGeneratedDocumentListVariated
' """
self.wanted_quantity = 1.0 self.wanted_quantity = 1.0
self.wanted_start_date = DateTime( self.wanted_start_date = DateTime(
str(self.datetime.earliestTime() + \ str(self.datetime.earliestTime() +
self.order_builder_hardcoded_time_diff)) self.order_builder_hardcoded_time_diff))
self.wanted_stop_date = self.wanted_start_date self.wanted_stop_date = self.wanted_start_date
...@@ -444,12 +351,12 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -444,12 +351,12 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
self.wanted_quantity = 1.0 self.wanted_quantity = 1.0
self.wanted_start_date = DateTime( self.wanted_start_date = DateTime(
str(self.datetime.earliestTime() \ str(self.datetime.earliestTime()
- self.max_delay \ - self.max_delay
+ self.order_builder_hardcoded_time_diff)) + self.order_builder_hardcoded_time_diff))
self.wanted_stop_date = DateTime( self.wanted_stop_date = DateTime(
str(self.datetime.earliestTime() \ str(self.datetime.earliestTime()
+ self.order_builder_hardcoded_time_diff)) + self.order_builder_hardcoded_time_diff))
sequence_list = SequenceList() sequence_list = SequenceList()
...@@ -465,7 +372,7 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase): ...@@ -465,7 +372,7 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
self.wanted_quantity = 1.0 self.wanted_quantity = 1.0
self.wanted_start_date = DateTime( self.wanted_start_date = DateTime(
str(self.datetime.earliestTime() \ str(self.datetime.earliestTime()
+ self.order_builder_hardcoded_time_diff)) + self.order_builder_hardcoded_time_diff))
self.wanted_stop_date = self.wanted_start_date self.wanted_stop_date = self.wanted_start_date
......
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