|
|
@@ -3,8 +3,7 @@ from decimal import Decimal as D
|
|
3
|
3
|
from http import client as http_client
|
|
4
|
4
|
from http.cookies import _unquote
|
|
5
|
5
|
|
|
6
|
|
-from django.conf import settings
|
|
7
|
|
-from django.test import TestCase
|
|
|
6
|
+from django.test import TestCase, override_settings
|
|
8
|
7
|
from django.urls import reverse
|
|
9
|
8
|
from django.utils.translation import gettext
|
|
10
|
9
|
|
|
|
@@ -93,13 +92,7 @@ class BasketSummaryViewTests(WebTestCase):
|
|
93
|
92
|
class BasketThresholdTest(WebTestCase):
|
|
94
|
93
|
csrf_checks = False
|
|
95
|
94
|
|
|
96
|
|
- def setUp(self):
|
|
97
|
|
- self._old_threshold = settings.OSCAR_MAX_BASKET_QUANTITY_THRESHOLD
|
|
98
|
|
- settings.OSCAR_MAX_BASKET_QUANTITY_THRESHOLD = 3
|
|
99
|
|
-
|
|
100
|
|
- def tearDown(self):
|
|
101
|
|
- settings.OSCAR_MAX_BASKET_QUANTITY_THRESHOLD = self._old_threshold
|
|
102
|
|
-
|
|
|
95
|
+ @override_settings(OSCAR_MAX_BASKET_QUANTITY_THRESHOLD=3)
|
|
103
|
96
|
def test_adding_more_than_threshold_raises(self):
|
|
104
|
97
|
dummy_product = create_product(price=D('10.00'), num_in_stock=10)
|
|
105
|
98
|
url = reverse('basket:add', kwargs={'pk': dummy_product.pk})
|
|
|
@@ -107,7 +100,7 @@ class BasketThresholdTest(WebTestCase):
|
|
107
|
100
|
'action': 'add',
|
|
108
|
101
|
'quantity': 2}
|
|
109
|
102
|
response = self.app.post(url, params=post_params)
|
|
110
|
|
- self.assertTrue('oscar_open_basket' in response.test_app.cookies)
|
|
|
103
|
+ self.assertIn('oscar_open_basket', response.test_app.cookies)
|
|
111
|
104
|
post_params = {'product_id': dummy_product.id,
|
|
112
|
105
|
'action': 'add',
|
|
113
|
106
|
'quantity': 2}
|
|
|
@@ -118,7 +111,7 @@ class BasketThresholdTest(WebTestCase):
|
|
118
|
111
|
"than %(threshold)d items in one order. Your basket currently "
|
|
119
|
112
|
"has %(basket)d items."
|
|
120
|
113
|
) % ({'threshold': 3, 'basket': 2})
|
|
121
|
|
- self.assertTrue(expected in response.test_app.cookies['messages'])
|
|
|
114
|
+ self.assertIn(expected, response.test_app.cookies['messages'])
|
|
122
|
115
|
|
|
123
|
116
|
|
|
124
|
117
|
class BasketReportTests(TestCase):
|