|
17 | 17 | from ..templatetags.fundraising_extras import ( |
18 | 18 | display_django_heroes, |
19 | 19 | donation_form_with_heart, |
| 20 | + gold_corporate_members, |
20 | 21 | top_corporate_members, |
21 | 22 | ) |
22 | 23 |
|
@@ -167,3 +168,51 @@ def test_with_diamond_members_and_platinum_members(self): |
167 | 168 | expected = [member_5, member_4, member_6, member_2, member_1, member_3] |
168 | 169 |
|
169 | 170 | self.assertEqual(members, expected) |
| 171 | + |
| 172 | + |
| 173 | +class TestGoldCorporateMembers(TestCase): |
| 174 | + past_date = date(2000, 1, 1) |
| 175 | + future_date = date(3000, 1, 1) |
| 176 | + |
| 177 | + def test_with_no_gold_members(self): |
| 178 | + members = gold_corporate_members()["members"] |
| 179 | + self.assertEqual(members, []) |
| 180 | + |
| 181 | + def test_with_gold_members(self): |
| 182 | + member_1 = CorporateMember.objects.create(membership_level=3) |
| 183 | + member_2 = CorporateMember.objects.create(membership_level=3) |
| 184 | + member_3 = CorporateMember.objects.create(membership_level=3) |
| 185 | + |
| 186 | + member_1.invoice_set.create(amount=4, expiration_date=self.future_date) |
| 187 | + member_2.invoice_set.create(amount=8, expiration_date=self.future_date) |
| 188 | + member_3.invoice_set.create(amount=2, expiration_date=self.future_date) |
| 189 | + |
| 190 | + members = gold_corporate_members()["members"] |
| 191 | + |
| 192 | + self.assertEqual(members, [member_2, member_1, member_3]) |
| 193 | + |
| 194 | + def test_with_gold_members_and_other_members(self): |
| 195 | + member_1 = CorporateMember.objects.create(membership_level=3) |
| 196 | + member_2 = CorporateMember.objects.create(membership_level=3) |
| 197 | + member_3 = CorporateMember.objects.create(membership_level=4) |
| 198 | + |
| 199 | + member_1.invoice_set.create(amount=4, expiration_date=self.future_date) |
| 200 | + member_2.invoice_set.create(amount=8, expiration_date=self.future_date) |
| 201 | + member_3.invoice_set.create(amount=2, expiration_date=self.future_date) |
| 202 | + |
| 203 | + members = gold_corporate_members()["members"] |
| 204 | + self.assertEqual(members, [member_2, member_1]) |
| 205 | + self.assertNotIn(member_3, members) |
| 206 | + |
| 207 | + def test_with_gold_members_and_expired_invoice(self): |
| 208 | + member_1 = CorporateMember.objects.create(membership_level=3) |
| 209 | + member_2 = CorporateMember.objects.create(membership_level=3) |
| 210 | + member_3 = CorporateMember.objects.create(membership_level=4) |
| 211 | + |
| 212 | + member_1.invoice_set.create(amount=4, expiration_date=self.future_date) |
| 213 | + member_2.invoice_set.create(amount=8, expiration_date=self.future_date) |
| 214 | + member_3.invoice_set.create(amount=2, expiration_date=self.past_date) |
| 215 | + |
| 216 | + members = gold_corporate_members()["members"] |
| 217 | + self.assertEqual(members, [member_2, member_1]) |
| 218 | + self.assertNotIn(member_3, members) |
0 commit comments