Commit 63470f87 authored by Łukasz Nowak's avatar Łukasz Nowak

Simplify and extend assertion.

Check for not only subscription packing lists.

Check document level and avoid playing too much with simulation as they are
tested in unit tests.
parent 3a8210fb
...@@ -371,27 +371,12 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -371,27 +371,12 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
def assertHostingSubscriptionSimulationCoverage(self, subscription): def assertHostingSubscriptionSimulationCoverage(self, subscription):
self.login() self.login()
applied_rule_list = self.portal.portal_catalog(portal_type='Applied Rule', # this is document level assertion, as simulation and its specific delivery
causality_uid=subscription.getUid()) # is covered by unit tests
self.assertEqual(1, len(applied_rule_list)) packing_list_line_list = subscription.getAggregateRelatedValueList(
applied_rule = applied_rule_list[0] portal_type='Sale Packing List Line')
simulation_movement_list = applied_rule.contentValues( self.assertTrue(len(packing_list_line_list) >= 2)
portal_type='Simulation Movement') for packing_list_line in packing_list_line_list:
self.assertNotEqual(0, len(simulation_movement_list))
open_sale_order_line_template = self.portal.restrictedTraverse(
self.portal.portal_preferences.getPreferredOpenSaleOrderLineTemplate())
for simulation_movement in simulation_movement_list:
self.assertEqual(open_sale_order_line_template.getResource(),
simulation_movement.getResource())
self.assertEqual(subscription.getRelativeUrl(),
simulation_movement.getAggregate())
self.assertEqual(subscription.getPeriodicityMonthDay(),
simulation_movement.getStartDate().day())
self.assertEqual(subscription.getPeriodicityMonthDay(),
simulation_movement.getStopDate().day())
packing_list_line = simulation_movement.getDeliveryValue()
self.assertNotEqual(None, packing_list_line)
packing_list = packing_list_line.getParentValue() packing_list = packing_list_line.getParentValue()
self.assertEqual('Sale Packing List', self.assertEqual('Sale Packing List',
packing_list.getPortalType()) packing_list.getPortalType())
...@@ -400,21 +385,10 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -400,21 +385,10 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
causality_state = packing_list.getCausalityState() causality_state = packing_list.getCausalityState()
self.assertEqual('solved', causality_state) self.assertEqual('solved', causality_state)
applied_rule_list_l2 = simulation_movement.contentValues( invoice_list = packing_list.getCausalityRelatedValueList(
portal_type='Applied Rule') portal_type='Sale Invoice Transaction')
self.assertEqual(1, len(applied_rule_list_l2)) self.assertEqual(1, len(invoice_list))
invoice_applied_rule = applied_rule_list_l2[0] invoice = invoice_list[0]
invoice_simulation_movement_list = invoice_applied_rule.contentValues(
portal_type='Simulation Movement')
self.assertEqual(1, len(invoice_simulation_movement_list))
invoice_simulation_movement = invoice_simulation_movement_list[0]
self.assertEqual(open_sale_order_line_template.getResource(),
invoice_simulation_movement.getResource())
self.assertEqual(subscription.getRelativeUrl(),
invoice_simulation_movement.getAggregate())
invoice_line = invoice_simulation_movement.getDeliveryValue()
self.assertNotEqual(None, invoice_line)
invoice = invoice_line.getParentValue()
self.assertEqual('Sale Invoice Transaction', self.assertEqual('Sale Invoice Transaction',
invoice.getPortalType()) invoice.getPortalType())
self.assertEqual('delivered', invoice.getSimulationState()) self.assertEqual('delivered', invoice.getSimulationState())
...@@ -427,13 +401,11 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -427,13 +401,11 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self.assertSameSet([invoice.getRelativeUrl()], self.assertSameSet([invoice.getRelativeUrl()],
packing_list.getCausalityRelatedList( packing_list.getCausalityRelatedList(
portal_type=self.portal.getPortalDeliveryTypeList())) portal_type=self.portal.getPortalDeliveryTypeList()))
# now use causality related to find payment, as walking through simulation
# is really complex
# simulation are tested in unit tests, here the assertions are made on
# document level
payment_list = invoice.getCausalityRelatedValueList( payment_list = invoice.getCausalityRelatedValueList(
portal_type=self.portal.getPortalDeliveryTypeList()) portal_type=self.portal.getPortalDeliveryTypeList())
if invoice.getTotalPrice() == 0:
self.assertEqual(0, len(payment_list))
else:
self.assertEqual(1, len(payment_list)) self.assertEqual(1, len(payment_list))
payment = payment_list[0] payment = payment_list[0]
self.assertEqual('Payment Transaction', self.assertEqual('Payment Transaction',
...@@ -448,6 +420,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin): ...@@ -448,6 +420,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self.assertSameSet([payment.getRelativeUrl()], self.assertSameSet([payment.getRelativeUrl()],
invoice.getCausalityRelatedList( invoice.getCausalityRelatedList(
portal_type=self.portal.getPortalDeliveryTypeList())) portal_type=self.portal.getPortalDeliveryTypeList()))
self.assertEqual(payment.PaymentTransaction_getTotalPayablePrice(),
invoice.getTotalPrice())
def assertOpenSaleOrderCoverage(self, person_reference): def assertOpenSaleOrderCoverage(self, person_reference):
self.login() self.login()
......
100 101
\ No newline at end of file \ No newline at end of file
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