Commit c5630292 authored by Łukasz Nowak's avatar Łukasz Nowak

Implement Sale Packing List checking.

parent aa637673
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 DateTime import DateTime
from testVifibOpenOrderSimulation import generateTimeFrameList
class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin): class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
...@@ -8,49 +11,70 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin): ...@@ -8,49 +11,70 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
self.portal.portal_alarms.vifib_trigger_build.activeSense() self.portal.portal_alarms.vifib_trigger_build.activeSense()
def stepCheckSubscriptionSalePackingListCoverage(self, sequence, **kw): def stepCheckSubscriptionSalePackingListCoverage(self, sequence, **kw):
raise NotImplementedError( hosting_subscription = self.portal.portal_catalog.getResultValue(
"Shall check that 12 SPLs are build to cover the whole year.") uid=sequence['hosting_subscription_uid'])
# check one more sale packing list is generated delivery_list = self.portal.portal_catalog(
# and only one sale packing list line is inside portal_type='Sale Packing List',
sale_packing_list = sequence['current_sale_packing_list'] causality_relative_url=hosting_subscription.getRelativeUrl(),
sale_packing_list_line_list = \ sort_on=(('delivery.start_date', 'desc'),)
sale_packing_list.contentValues(portal_type="Sale Packing List Line") )
self.assertEquals(1, len(sale_packing_list_line_list)) # is whole year covered?
sale_packing_list_line = sale_packing_list_line_list[0] self.assertEqual(12, len(delivery_list))
# check sale packing list related property # generate the expected time frames
self.assertEquals("organisation_module/vifib_internet", now = DateTime()
sale_packing_list.getSource()) start_date = \
self.assertEquals("organisation_module/vifib_internet", getClosestDate(target_date=now, precision='day', before=1)
sale_packing_list.getSourceSection())
self.assertEquals("person_module/test_vifib_customer", # Calculate the list of time frames
sale_packing_list.getDestination()) expected_time_frame_list = generateTimeFrameList(start_date)
self.assertEquals("person_module/test_vifib_customer",
sale_packing_list.getDestinationSection()) idx = 0
self.assertEquals("currency_module/EUR", for delivery in delivery_list:
sale_packing_list.getPriceCurrency()) expected_start_date = expected_time_frame_list[idx]
expected_stop_date = expected_time_frame_list[idx+1]
# check sale packing list line related property self.assertEqual(expected_start_date, delivery.getStartDate())
self.assertEquals("service_module/vifib_instance_subscription", self.assertEqual(expected_stop_date, delivery.getStopDate())
sale_packing_list_line.getResource())
self.assertEquals(1, self.assertEqual(hosting_subscription.getRelativeUrl(),
sale_packing_list_line.getQuantity()) delivery.getCausality())
self.assertEquals("unit/piece", delivery_line_list = \
sale_packing_list_line.getQuantityUnit()) delivery.contentValues(portal_type="Sale Packing List Line")
self.assertEquals(1, self.assertEquals(1, len(delivery_line_list))
sale_packing_list_line.getPrice()) delivery_line = delivery_line_list[0]
self.assertEquals("organisation_module/vifib_internet",
# fetch open order, open order line and subscription delivery.getSource())
person = self.portal.person_module['test_vifib_customer'] self.assertEquals("organisation_module/vifib_internet",
open_order = \ delivery.getSourceSection())
person.getDestinationDecisionRelatedValue(portal_type="Open Sale Order") self.assertEquals("person_module/test_vifib_customer",
open_order_line = \ delivery.getDestination())
open_order.contentValues(portal_type="Open Sale Order Line")[0] self.assertEquals("person_module/test_vifib_customer",
delivery.getDestinationSection())
# check related property self.assertEquals("currency_module/EUR",
self.assertEquals(open_order_line.getSpecialise(), delivery.getPriceCurrency())
sale_packing_list.getSpecialise())
# check sale packing list line related property
self.assertEquals("service_module/vifib_instance_subscription",
delivery_line.getResource())
self.assertEquals(1,
delivery_line.getQuantity())
self.assertEquals("unit/piece",
delivery_line.getQuantityUnit())
self.assertEquals(1,
delivery_line.getPrice())
# fetch open order, open order line and subscription
person = self.portal.person_module['test_vifib_customer']
open_order = \
person.getDestinationDecisionRelatedValue(portal_type="Open Sale Order")
open_order_line = \
open_order.contentValues(portal_type="Open Sale Order Line")[0]
# check related property
self.assertEquals(open_order_line.getSpecialise(),
delivery.getSpecialise())
idx += 1
def stepCheckOneMoreDocumentList(self, sequence, **kw): def stepCheckOneMoreDocumentList(self, sequence, **kw):
hosting_subscription = self.portal.portal_catalog\ hosting_subscription = self.portal.portal_catalog\
...@@ -117,6 +141,7 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin): ...@@ -117,6 +141,7 @@ class TestVifibInstanceHostingRelatedDocument(TestVifibSlapWebServiceMixin):
""" """
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
raise NotImplementedError('Cover various cases of triggering build')
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
...@@ -5,6 +5,14 @@ from testVifibSlapWebService import TestVifibSlapWebServiceMixin ...@@ -5,6 +5,14 @@ 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):
...@@ -76,11 +84,7 @@ class TestVifibOpenOrderSimulation(TestVifibSlapWebServiceMixin): ...@@ -76,11 +84,7 @@ 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_list = [start_date] expected_time_frame_list = generateTimeFrameList(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))
# test the test: have we generated 12th next months coverage? # test the test: have we generated 12th next months coverage?
self.assertEqual(13, len(expected_time_frame_list)) self.assertEqual(13, len(expected_time_frame_list))
......
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