Commit 7cce6cde authored by Jérome Perrin's avatar Jérome Perrin

test: add an edge case test for getPrice when the movement has an invalidated trade condition

parent 3759047d
......@@ -446,6 +446,40 @@ class TestTradeConditionSupplyLine(TradeConditionTestCase):
# not using the supply line inside trade condition
self.assertEqual(1, line.getPrice())
def test_supply_line_in_invalidated_trade_condition_with_reference_does_not_apply(self):
# edge case derived from
# test_supply_line_in_invalidated_trade_condition_does_not_apply, if a
# trade condition have a reference and is invalidated, composition
# mechanism will lookup another applicable trade condition, which can fail,
# but this should not affect getPrice
other_supply = self.portal.getDefaultModule(self.supply_type
).newContent(portal_type=self.supply_type,
resource_value=self.resource,
source_section_value=self.vendor,
destination_section_value=self.client)
other_supply.validate()
other_supply_line = other_supply.newContent(
portal_type=self.supply_line_type,
base_price=1)
self.trade_condition.setReference(self.id())
supply_line = self.trade_condition.newContent(
portal_type=self.supply_line_type,
resource_value=self.resource,
base_price=2)
self.order.setSpecialiseValue(self.trade_condition)
self.order.setSourceSectionValue(self.vendor)
self.order.setDestinationSectionValue(self.client)
self.trade_condition.invalidate()
self.tic()
line = self.order.newContent(portal_type=self.order_line_type,
resource_value=self.resource,
quantity=1)
# not using the supply line inside trade condition
self.assertEqual(1, line.getPrice())
# TODO: move to testSupplyLine ! (which does not exist yet)
def test_supply_line_section(self):
# if a supply lines defines a section, it has priority over supply lines
......
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