X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/002577cf05a6730e8b1c97d1931d79758cbcbfdc..59c600057d146153b272cc770cb0e00221540fda:/apps/funding/tests.py diff --git a/apps/funding/tests.py b/apps/funding/tests.py index c9438a878..6321f96b6 100644 --- a/apps/funding/tests.py +++ b/apps/funding/tests.py @@ -2,27 +2,29 @@ # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # +from datetime import date, timedelta from django.test import TestCase from .models import Offer, Perk, Funding class FundTest(TestCase): def setUp(self): + self.today = date.today() self.offer1 = Offer.objects.create( author='author1', title='title1', slug='slug1', - target=100, start='2013-03-01', end='2013-03-31') + target=100, start=self.today, end=self.today) def test_perks(self): perk = Perk.objects.create(price=20, name='Perk 20') perk1 = Perk.objects.create(offer=self.offer1, price=50, name='Perk 50') offer2 = Offer.objects.create( author='author2', title='title2', slug='slug2', - target=100, start='2013-02-01', end='2013-02-20') + target=100, start=self.today-timedelta(1), end=self.today-timedelta(1)) perk2 = Perk.objects.create(offer=offer2, price=1, name='Perk 1') self.assertEqual( - set(self.offer1.fund('Tester', 'test@example.com', 10).perks.all()), + set(self.offer1.get_perks(10)), set()) self.assertEqual( - set(self.offer1.fund('Tester', 'test@example.com', 70).perks.all()), + set(self.offer1.get_perks(70)), set([perk, perk1]))