Commit 45d912c5 authored by Łukasz Nowak's avatar Łukasz Nowak

Update start and stop date assertions.

Also drop not needed methods.
parent 935ebff4
import unittest import unittest
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList
from testVifibSlapWebService import TestVifibSlapWebServiceMixin from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from Products.ERP5Type.DateUtils import getClosestDate from Products.ERP5Type.DateUtils import getClosestDate, getNumberOfDayInMonth
from DateTime import DateTime from DateTime import DateTime
from testVifibOpenOrderSimulation import generateTimeFrameList
class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin): class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
...@@ -18,20 +17,24 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin): ...@@ -18,20 +17,24 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
# is next month covered? # is next month covered?
self.assertEqual(1, len(delivery_list)) self.assertEqual(1, len(delivery_list))
# generate the expected time frames instance_setup_delivery = self.portal.portal_catalog.getResultValue(
now = DateTime() portal_type='Sale Packing List Line',
start_date = \ default_aggregate_uid=sequence['software_instance_uid'],
getClosestDate(target_date=now, precision='day', before=1) resource=self.portal.portal_preferences\
.getPreferredInstanceSetupResource()).getParentValue()
# Calculate the list of time frames
expected_time_frame_list = generateTimeFrameList(start_date) self.assertEqual('stopped', instance_setup_delivery.getSimulationState())
start_date = None
for item in self.portal.portal_workflow.getInfoFor(
ob=instance_setup_delivery, name='history', wf_id='packing_list_workflow'):
if item.get('simulation_state') == 'stopped':
start_date = item.get('time')
break
stop_date = start_date + getNumberOfDayInMonth(start_date)
idx = 0 idx = 0
for delivery in delivery_list: for delivery in delivery_list:
expected_start_date = expected_time_frame_list[idx] self.assertEqual(start_date, delivery.getStartDate())
expected_stop_date = expected_time_frame_list[idx+1] self.assertEqual(stop_date, delivery.getStopDate())
self.assertEqual(expected_start_date, delivery.getStartDate())
self.assertEqual(expected_stop_date, delivery.getStopDate())
self.assertEqual(hosting_subscription.getRelativeUrl(), self.assertEqual(hosting_subscription.getRelativeUrl(),
delivery.getCausality()) delivery.getCausality())
......
...@@ -5,14 +5,6 @@ from testVifibSlapWebService import TestVifibSlapWebServiceMixin ...@@ -5,14 +5,6 @@ from testVifibSlapWebService import TestVifibSlapWebServiceMixin
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
def generateTimeFrameList(start_date):
expected_time_frame_list = [start_date]
current = \
getClosestDate(target_date=start_date, precision='month', before=0)
for m in range(0, 12):
expected_time_frame_list.append(addToDate(current, month=m))
return expected_time_frame_list
class TestVifibOpenOrderSimulation(TestVifibSlapWebServiceMixin): class TestVifibOpenOrderSimulation(TestVifibSlapWebServiceMixin):
def stepCheckSimulationMovement(self, sequence, **kw): def stepCheckSimulationMovement(self, sequence, **kw):
......
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