|
@@ -67,3 +67,27 @@ async def test_base_at_or_below_floor_drops_discount(monkeypatch):
|
|
|
data = {d: DiscountData(type=DiscountType.PERCENT, value=10)}
|
|
data = {d: DiscountData(type=DiscountType.PERCENT, value=10)}
|
|
|
result = await run(d, d, data)
|
|
result = await run(d, d, data)
|
|
|
assert d not in result
|
|
assert d not in result
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+@pytest.mark.asyncio
|
|
|
|
|
+async def test_negative_value_surcharge_passes_through_unclamped(monkeypatch):
|
|
|
|
|
+ # same_day's -15% surcharge hack must survive min_price untouched, even though
|
|
|
|
|
+ # it would otherwise be mistaken for a discount clamped away to nothing.
|
|
|
|
|
+ d = date(2026, 1, 10)
|
|
|
|
|
+ _stub_prices(monkeypatch, {d: 100})
|
|
|
|
|
+ _stub_config(monkeypatch, 52)
|
|
|
|
|
+ data = {d: DiscountData(type=DiscountType.PERCENT, value=-15)}
|
|
|
|
|
+ result = await run(d, d, data)
|
|
|
|
|
+ assert result[d].value == -15
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+@pytest.mark.asyncio
|
|
|
|
|
+async def test_negative_value_surcharge_passes_through_below_floor(monkeypatch):
|
|
|
|
|
+ # Even when base is at/below the floor (which drops a normal discount entirely),
|
|
|
|
|
+ # a surcharge has nothing to do with the floor and must still pass through.
|
|
|
|
|
+ d = date(2026, 1, 10)
|
|
|
|
|
+ _stub_prices(monkeypatch, {d: 50})
|
|
|
|
|
+ _stub_config(monkeypatch, 52)
|
|
|
|
|
+ data = {d: DiscountData(type=DiscountType.PERCENT, value=-15)}
|
|
|
|
|
+ result = await run(d, d, data)
|
|
|
|
|
+ assert result[d].value == -15
|