def test_unicode(self): """ Verify that unicode methods work for Member, GP and Membership """ project = GivingProject(title=u'Â Fake Giving Project', fundraising_training=timezone.now(), fundraising_deadline=timezone.now()) project.save() member = Member(first_name='Al', last_name=u'Fiüsher') member.save() membership = Membership(giving_project=project, member=member) self.assertEqual(u'Al Fiüsher', unicode(member)) self.assertEqual(u'Â Fake Giving Project %d' % timezone.now().year, unicode(project)) self.assertEqual(u'Al Fiüsher, Â Fake Giving Project %d' % timezone.now().year, unicode(membership))
def test_load(self): self.login_as_member('current') now = timezone.now() # create GPs that should be hidden yesterday = now - timedelta(days=1) private_gp = GivingProject(title='Private Group', fundraising_training=yesterday, fundraising_deadline=now + timedelta(days=40), public=False) private_gp.save() past_gp = GivingProject(title='Ye Olde Projecte', fundraising_training=yesterday, fundraising_deadline=yesterday) past_gp.save() res = self.client.get(MANAGE_ACCOUNT_URL) self.assertEqual(res.status_code, 200) self.assertTemplateUsed(res, 'fund/account_projects.html') expected_gps = GivingProject.objects.filter(public=True, fundraising_deadline__gte=now) gp_choices = res.context['form'].fields.get('giving_project').choices self.assertEqual(len(gp_choices), expected_gps.count() + 1) # 1 blank choice gp_ids = [int(choice[0]) for choice in gp_choices if choice[0]] self.assertNotIn(private_gp.pk, gp_ids) self.assertNotIn(past_gp.pk, gp_ids)
def test_unicode(self): """ Verify that unicode methods work for Member, GP and Membership """ project = GivingProject(title=u'Â Fake Giving Project', fundraising_training=timezone.now(), fundraising_deadline=timezone.now()) project.save() member = Member.objects.create_with_user(first_name='Al', last_name=u'Fiüsher', email='*****@*****.**', password='******') membership = Membership(giving_project=project, member=member) self.assertEqual(u'Al Fiüsher', unicode(member)) self.assertEqual(u'Â Fake Giving Project %d' % timezone.now().year, unicode(project)) self.assertEqual( u'Al Fiüsher, Â Fake Giving Project %d' % timezone.now().year, unicode(membership))
def test_load(self): self.login_as_member('current') now = timezone.now() # create GPs that should be hidden yesterday = now - timedelta(days=1) private_gp = GivingProject(title='Private Group', fundraising_training=yesterday, fundraising_deadline=now + timedelta(days=40), public=False) private_gp.save() past_gp = GivingProject(title='Ye Olde Projecte', fundraising_training=yesterday, fundraising_deadline=yesterday) past_gp.save() res = self.client.get(self.url) self.assertEqual(res.status_code, 200) self.assertTemplateUsed(res, 'fund/account_projects.html') expected_gps = GivingProject.objects.filter(public=True, fundraising_deadline__gte=now) gp_choices = res.context['form'].fields.get('giving_project').choices self.assertEqual(len(gp_choices), expected_gps.count() + 1) # 1 blank choice gp_ids = [int(choice[0]) for choice in gp_choices if choice[0]] self.assertNotIn(private_gp.pk, gp_ids) self.assertNotIn(past_gp.pk, gp_ids)