Commit 38c1eacc authored by Łukasz Nowak's avatar Łukasz Nowak

Stop date is exclusive.

parent 71f99fb5
import unittest import unittest
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.DateUtils import getClosestDate, addToDate, \ from Products.ERP5Type.DateUtils import getClosestDate, addToDate
atTheEndOfPeriod
from testVifibSlapWebService import TestVifibSlapWebServiceMixin from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
...@@ -77,32 +76,29 @@ class TestVifibOpenOrderSimulation(TestVifibSlapWebServiceMixin): ...@@ -77,32 +76,29 @@ class TestVifibOpenOrderSimulation(TestVifibSlapWebServiceMixin):
0.0, open_order_line.getStopDate().second()) 0.0, open_order_line.getStopDate().second())
# Calculate the list of time frames # Calculate the list of time frames
expected_time_frame_tuple_list = [(start_date, (atTheEndOfPeriod(start_date, 'month') - 1).latestTime())] expected_time_frame_list = [start_date]
# now 11 months in form: 2022/02/01 00:00, 2022/02/28 23:59
current = \ current = \
getClosestDate(target_date=start_date, precision='month', before=1) getClosestDate(target_date=start_date, precision='month', before=0)
for m in range(1, 12): for m in range(0, 12):
expected_time_frame_tuple_list.append((current, (addToDate(current, month=1)-1).latestTime())) expected_time_frame_list.append(addToDate(current, month=m))
current = addToDate(current, month=1)
# test the test: have we generated 12th months coverage? # test the test: have we generated 12th next months coverage?
self.assertEqual(12, len(expected_time_frame_tuple_list)) self.assertEqual(13, len(expected_time_frame_list))
simulation_movement_list = self.portal.portal_catalog( simulation_movement_list = self.portal.portal_catalog(
portal_type='Simulation Movement', portal_type='Simulation Movement',
parent_uid=applied_rule.getUid(), parent_uid=applied_rule.getUid(),
sort_on=(('movement.start_date', 'desc'),) sort_on=(('movement.start_date', 'desc'),)
) )
# Check that simulation is created by the periodicity # Check that simulation is created by the periodicity for one year
self.assertEquals(len(expected_time_frame_tuple_list), self.assertEquals(12,
len(simulation_movement_list)) len(simulation_movement_list))
# Check the list of expected simulation # Check the list of expected simulation
idx = 0 idx = 0
for simulation_movement in simulation_movement_list: for simulation_movement in simulation_movement_list:
excepted_start_date = expected_time_frame_tuple_list[idx][0] excepted_start_date = expected_time_frame_list[idx]
excepted_stop_date = expected_time_frame_tuple_list[idx][1] excepted_stop_date = expected_time_frame_list[idx+1]
idx += 1
# Check simulation movement property # Check simulation movement property
self.assertEquals(1.0, self.assertEquals(1.0,
simulation_movement.getQuantity()) simulation_movement.getQuantity())
......
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