|
|
@@ -1,6 +1,7 @@
|
|
1
|
1
|
|
|
2
|
2
|
import pytest
|
|
3
|
3
|
|
|
|
4
|
+from oscar.apps.offer import models
|
|
4
|
5
|
from oscar.apps.offer.applicator import Applicator
|
|
5
|
6
|
from oscar.test.factories import (
|
|
6
|
7
|
BasketFactory, ConditionalOfferFactory, ProductFactory)
|
|
|
@@ -58,6 +59,25 @@ class TestLineOfferConsumer:
|
|
58
|
59
|
for line in filled_basket.all_lines():
|
|
59
|
60
|
assert line.consumer.consumed() == 0
|
|
60
|
61
|
|
|
|
62
|
+ def test_available_with_offer(self):
|
|
|
63
|
+ basket = BasketFactory()
|
|
|
64
|
+ product1 = ProductFactory()
|
|
|
65
|
+ product2 = ProductFactory()
|
|
|
66
|
+ basket.add_product(product1, quantity=1)
|
|
|
67
|
+ basket.add_product(product2, quantity=10)
|
|
|
68
|
+
|
|
|
69
|
+ benefit = models.Benefit(
|
|
|
70
|
+ type=models.Benefit.PERCENTAGE,
|
|
|
71
|
+ value=10,
|
|
|
72
|
+ max_affected_items=5,
|
|
|
73
|
+ )
|
|
|
74
|
+ benefit.save()
|
|
|
75
|
+
|
|
|
76
|
+ offer1 = ConditionalOfferFactory(name='offer1', benefit=benefit)
|
|
|
77
|
+ lines = basket.all_lines()
|
|
|
78
|
+ assert lines[0].consumer.available(offer1) == 1
|
|
|
79
|
+ assert lines[1].consumer.available(offer1) == 5
|
|
|
80
|
+
|
|
61
|
81
|
def test_consumed_with_offer(self, filled_basket):
|
|
62
|
82
|
offer1 = ConditionalOfferFactory(name='offer1')
|
|
63
|
83
|
offer2 = ConditionalOfferFactory(name='offer2')
|