Remove funding.offer.due.
[wolnelektury.git] / apps / funding / tests.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from datetime import date, timedelta
6 from django.test import TestCase
7 from .models import Offer, Perk, Funding
8
9
10 class FundTest(TestCase):
11     def setUp(self):
12         self.today = date.today()
13         self.offer1 = Offer.objects.create(
14             author='author1', title='title1', slug='slug1',
15             target=100, start=self.today, end=self.today)
16
17     def test_perks(self):
18         perk = Perk.objects.create(price=20, name='Perk 20')
19         perk1 = Perk.objects.create(offer=self.offer1, price=50, name='Perk 50')
20         offer2 = Offer.objects.create(
21             author='author2', title='title2', slug='slug2',
22             target=100, start=self.today-timedelta(1), end=self.today-timedelta(1))
23         perk2 = Perk.objects.create(offer=offer2, price=1, name='Perk 1')
24
25         self.assertEqual(
26             set(self.offer1.get_perks(10)),
27             set())
28         self.assertEqual(
29             set(self.offer1.get_perks(70)),
30             set([perk, perk1]))