Skip to content

Commit

Permalink
Split offer tests into unit/integration folders
Browse files Browse the repository at this point in the history
This might be futile.
  • Loading branch information
codeinthehole committed Dec 3, 2012
1 parent a84bb16 commit e5d7843
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions oscar/apps/offer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ def _included_product_ids(self):
return self.__included_product_ids

def _excluded_product_ids(self):
if not self.id:
return []
if None == self.__excluded_product_ids:
self.__excluded_product_ids = [row['id'] for row in self.excluded_products.values('id')]
return self.__excluded_product_ids
Expand Down
5 changes: 4 additions & 1 deletion tests/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ Tests are split into 3 folders:

* functional - These should be as close to "end-to-end" as possible. Most of
these tests should use WebTest to simulate the behaviour of a user browsing
the site.
the site.

The 'integration' folder is relatively new and the process of migrating tests
from 'unit' is in place.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class TestCountCondition(OfferTest):

def setUp(self):
super(TestCountCondition, self).setUp()
self.condition = models.CountCondition(range=self.range,
type="Count", value=2)
self.condition = models.CountCondition(
range=self.range, type="Count", value=2)

def test_is_not_satified_by_empty_basket(self):
self.assertFalse(self.condition.is_satisfied(self.basket))
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import datetime

from django.conf import settings
from django.test import TestCase

Expand All @@ -10,7 +8,7 @@
class TestWholeSiteRangeWithGlobalBlacklist(TestCase):

def setUp(self):
self.range = models.Range.objects.create(
self.range = models.Range(
name="All products", includes_all_products=True)

def tearDown(self):
Expand All @@ -22,20 +20,23 @@ def test_blacklisting_prevents_products_being_in_range(self):
self.assertFalse(self.range.contains_product(prod))

def test_blacklisting_can_use_product_class(self):
settings.OSCAR_OFFER_BLACKLIST_PRODUCT = lambda p: p.product_class.name == 'giftcard'
settings.OSCAR_OFFER_BLACKLIST_PRODUCT = (
lambda p: p.product_class.name == 'giftcard')
prod = create_product(product_class="giftcard")
self.assertFalse(self.range.contains_product(prod))

def test_blacklisting_doesnt_exlude_everything(self):
settings.OSCAR_OFFER_BLACKLIST_PRODUCT = lambda p: p.product_class.name == 'giftcard'
settings.OSCAR_OFFER_BLACKLIST_PRODUCT = (
lambda p: p.product_class.name == 'giftcard')
prod = create_product(product_class="book")
self.assertTrue(self.range.contains_product(prod))


class TestWholeSiteRange(TestCase):

def setUp(self):
self.range = models.Range.objects.create(name="All products", includes_all_products=True)
self.range = models.Range.objects.create(
name="All products", includes_all_products=True)
self.prod = create_product()

def test_all_products_range(self):
Expand Down
File renamed without changes.

0 comments on commit e5d7843

Please sign in to comment.