Commit 8461cb86 authored by Łukasz Nowak's avatar Łukasz Nowak

Simplify the test.

parent 4fa2d2b1
...@@ -320,100 +320,13 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder): ...@@ -320,100 +320,13 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
) )
person = self.portal.person_module.template_member\ person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
delivery_kw = dict(
portal_type='Sale Packing List',
causality=hosting_subscription.getRelativeUrl(),
price_currency='currency_module/EUR',
source='organisation_module/slapos',
source_section='organisation_module/slapos',
specialise='sale_trade_condition_module/slapos_trade_condition',
)
delivery_line_kw = dict(
portal_type='Sale Packing List Line',
resource='service_module/slapos_instance_subscription',
use='trade/sale',
quantity_unit='unit/piece',
base_contribution_list=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
aggregate=hosting_subscription.getRelativeUrl(),
)
delivery_1 = self.portal.sale_packing_list_module.newContent(
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
**delivery_kw
)
self.portal.portal_workflow._jumpToStateFor(delivery_1, 'delivered')
self.portal.portal_workflow._jumpToStateFor(delivery_1, 'calculating')
delivery_line_1 = delivery_1.newContent(
quantity=1.2,
price=3.4,
**delivery_line_kw
)
delivery_2 = self.portal.sale_packing_list_module.newContent(
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
**delivery_kw
)
self.portal.portal_workflow._jumpToStateFor(delivery_2, 'delivered')
self.portal.portal_workflow._jumpToStateFor(delivery_2, 'calculating')
delivery_line_2 = delivery_2.newContent(
quantity=5.6,
price=7.8,
**delivery_line_kw
)
simulation_movement_kw = dict(
portal_type='Simulation Movement',
aggregate=hosting_subscription.getRelativeUrl(),
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
causality=['business_process_module/slapos_sale_business_process'
'/deliver', 'business_process_module/slapos_sale_business_pr'
'ocess/delivery_path'],
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
price_currency='currency_module/EUR',
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source='organisation_module/slapos',
source_section='organisation_module/slapos',
specialise='sale_trade_condition_module/slapos_trade_condition',
trade_phase='slapos/delivery',
use='trade/sale',
delivery_ratio=1.0
)
simulation_movement_1 = applied_rule.newContent( simulation_movement_1 = applied_rule.newContent(
quantity=delivery_line_1.getQuantity(), portal_type='Simulation Movement'
price=delivery_line_1.getPrice(),
start_date=delivery_1.getStartDate(),
stop_date=delivery_1.getStopDate(),
delivery=delivery_line_1.getRelativeUrl(),
**simulation_movement_kw
) )
simulation_movement_2 = applied_rule.newContent( simulation_movement_2 = applied_rule.newContent(
quantity=delivery_line_2.getQuantity(), portal_type='Simulation Movement'
price=delivery_line_2.getPrice(),
start_date=delivery_2.getStartDate(),
stop_date=delivery_2.getStopDate(),
delivery=delivery_line_2.getRelativeUrl(),
**simulation_movement_kw
) )
self.tic()
delivery_1.updateCausalityState(solve_automatically=False)
delivery_2.updateCausalityState(solve_automatically=False)
self.tic()
# test the test
self.assertEqual('solved', delivery_1.getCausalityState())
self.assertEqual('solved', delivery_2.getCausalityState())
# linked invoice # linked invoice
invoice_kw = dict( invoice_kw = dict(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
...@@ -434,33 +347,31 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder): ...@@ -434,33 +347,31 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
) )
invoice_1 = self.portal.accounting_module.newContent( invoice_1 = self.portal.accounting_module.newContent(
causality=delivery_1.getRelativeUrl(), start_date=DateTime('2012/01/01'),
start_date=delivery_1.getStartDate(), stop_date=DateTime('2012/02/01'),
stop_date=delivery_1.getStopDate(), destination=person.getRelativeUrl(),
destination=delivery_1.getDestination(), destination_section=person.getRelativeUrl(),
destination_section=delivery_1.getDestinationSection(), destination_decision=person.getRelativeUrl(),
destination_decision=delivery_1.getDestinationDecision(),
**invoice_kw **invoice_kw
) )
invoice_line_1 = invoice_1.newContent( invoice_line_1 = invoice_1.newContent(
aggregate=delivery_line_1.getAggregate(), aggregate=hosting_subscription.getRelativeUrl(),
price=delivery_line_1.getPrice(), price=1.2,
quantity=delivery_line_1.getQuantity(), quantity=3.4,
**invoice_line_kw **invoice_line_kw
) )
invoice_2 = self.portal.accounting_module.newContent( invoice_2 = self.portal.accounting_module.newContent(
causality=delivery_2.getRelativeUrl(), start_date=DateTime('2012/01/01'),
start_date=delivery_2.getStartDate(), stop_date=DateTime('2012/02/01'),
stop_date=delivery_2.getStopDate(), destination=person.getRelativeUrl(),
destination=delivery_2.getDestination(), destination_section=person.getRelativeUrl(),
destination_section=delivery_2.getDestinationSection(), destination_decision=person.getRelativeUrl(),
destination_decision=delivery_2.getDestinationDecision(),
**invoice_kw **invoice_kw
) )
invoice_line_2 = invoice_2.newContent( invoice_line_2 = invoice_2.newContent(
aggregate=delivery_line_2.getAggregate(), aggregate=hosting_subscription.getRelativeUrl(),
price=delivery_line_2.getPrice(), price=5.6,
quantity=delivery_line_2.getQuantity(), quantity=7.8,
**invoice_line_kw **invoice_line_kw
) )
self.portal.portal_workflow._jumpToStateFor(invoice_1, 'confirmed') self.portal.portal_workflow._jumpToStateFor(invoice_1, 'confirmed')
...@@ -469,15 +380,28 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder): ...@@ -469,15 +380,28 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
self.portal.portal_workflow._jumpToStateFor(invoice_2, 'calculating') self.portal.portal_workflow._jumpToStateFor(invoice_2, 'calculating')
# create new simulation movements # create new simulation movements
invoice_movement_kw = simulation_movement_kw.copy() invoice_movement_kw = dict(
invoice_movement_kw.update(
causality=[ causality=[
'business_process_module/slapos_sale_business_process/invoice', 'business_process_module/slapos_sale_business_process/invoice',
'business_process_module/slapos_sale_business_process/invoice_path' 'business_process_module/slapos_sale_business_process/invoice_path'
], ],
trade_phase='slapos/invoicing', trade_phase='slapos/invoicing',
delivery_ratio=1.0, delivery_ratio=1.0,
delivery_error=0.0 delivery_error=0.0,
portal_type='Simulation Movement',
aggregate=hosting_subscription.getRelativeUrl(),
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
price_currency='currency_module/EUR',
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source='organisation_module/slapos',
source_section='organisation_module/slapos',
specialise='sale_trade_condition_module/slapos_trade_condition',
use='trade/sale',
) )
invoice_rule_1 = simulation_movement_1.newContent( invoice_rule_1 = simulation_movement_1.newContent(
portal_type='Applied Rule', portal_type='Applied Rule',
......
120 121
\ 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