Skip to content

Commit e5d7843

Browse files
committed
Split offer tests into unit/integration folders
This might be futile.
1 parent a84bb16 commit e5d7843

13 files changed

+15
-9
lines changed

oscar/apps/offer/models.py

+2
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,8 @@ def _included_product_ids(self):
660660
return self.__included_product_ids
661661

662662
def _excluded_product_ids(self):
663+
if not self.id:
664+
return []
663665
if None == self.__excluded_product_ids:
664666
self.__excluded_product_ids = [row['id'] for row in self.excluded_products.values('id')]
665667
return self.__excluded_product_ids

tests/README.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ Tests are split into 3 folders:
1313

1414
* functional - These should be as close to "end-to-end" as possible. Most of
1515
these tests should use WebTest to simulate the behaviour of a user browsing
16-
the site.
16+
the site.
17+
18+
The 'integration' folder is relatively new and the process of migrating tests
19+
from 'unit' is in place.

tests/integration/offer/__init__.py

Whitespace-only changes.

tests/unit/offer/condition_tests.py tests/integration/offer/condition_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class TestCountCondition(OfferTest):
1212

1313
def setUp(self):
1414
super(TestCountCondition, self).setUp()
15-
self.condition = models.CountCondition(range=self.range,
16-
type="Count", value=2)
15+
self.condition = models.CountCondition(
16+
range=self.range, type="Count", value=2)
1717

1818
def test_is_not_satified_by_empty_basket(self):
1919
self.assertFalse(self.condition.is_satisfied(self.basket))

tests/unit/offer/range_tests.py tests/integration/offer/range_tests.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import datetime
2-
31
from django.conf import settings
42
from django.test import TestCase
53

@@ -10,7 +8,7 @@
108
class TestWholeSiteRangeWithGlobalBlacklist(TestCase):
119

1210
def setUp(self):
13-
self.range = models.Range.objects.create(
11+
self.range = models.Range(
1412
name="All products", includes_all_products=True)
1513

1614
def tearDown(self):
@@ -22,20 +20,23 @@ def test_blacklisting_prevents_products_being_in_range(self):
2220
self.assertFalse(self.range.contains_product(prod))
2321

2422
def test_blacklisting_can_use_product_class(self):
25-
settings.OSCAR_OFFER_BLACKLIST_PRODUCT = lambda p: p.product_class.name == 'giftcard'
23+
settings.OSCAR_OFFER_BLACKLIST_PRODUCT = (
24+
lambda p: p.product_class.name == 'giftcard')
2625
prod = create_product(product_class="giftcard")
2726
self.assertFalse(self.range.contains_product(prod))
2827

2928
def test_blacklisting_doesnt_exlude_everything(self):
30-
settings.OSCAR_OFFER_BLACKLIST_PRODUCT = lambda p: p.product_class.name == 'giftcard'
29+
settings.OSCAR_OFFER_BLACKLIST_PRODUCT = (
30+
lambda p: p.product_class.name == 'giftcard')
3131
prod = create_product(product_class="book")
3232
self.assertTrue(self.range.contains_product(prod))
3333

3434

3535
class TestWholeSiteRange(TestCase):
3636

3737
def setUp(self):
38-
self.range = models.Range.objects.create(name="All products", includes_all_products=True)
38+
self.range = models.Range.objects.create(
39+
name="All products", includes_all_products=True)
3940
self.prod = create_product()
4041

4142
def test_all_products_range(self):
File renamed without changes.

0 commit comments

Comments
 (0)