def test_early(self): """ org has an award, but agreement has not been mailed. verify not shown """ award = GivingProjectGrant(projectapp_id=1, amount=9000, first_yer_due=timezone.now() + timedelta(weeks=53)) award.save() response = self.client.get(self.url) self.assertTemplateUsed(response, self.template) self.assertNotContains(response, 'Agreement mailed')
def setUp(self): papp = ProjectApp(application_id=1, giving_project_id=1) papp.save() award = GivingProjectGrant(projectapp_id=papp.pk, amount=8900, first_yer_due=timezone.now()) award.save() yer = YearEndReport( award=award, total_size=83, donations_count_prev=6, donations_count=9, other_comments='Critical feedback' ) yer.save() self.yer_id = yer.pk
def test_sent(self): """ org has award, agreement mailed. verify shown """ today = timezone.now() award = GivingProjectGrant( projectapp_id=1, amount=9000, agreement_mailed=today - timedelta(days=1), first_yer_due=today + timedelta(weeks=52)) award.save() response = self.client.get(self.url) self.assertTemplateUsed(response, self.template) self.assertContains(response, 'Agreement mailed')
def test_merge_both_have_objs(self): cycles = factories.GrantCycle.create_batch(5) a = factories.Organization() factories.GrantApplication.create_batch(2, organization=a) factories.SponsoredProgramGrant(organization=a) b = factories.Organization() app = factories.GrantApplication(organization=b) # get draft & app IDs that were associated with secondary org sec_apps = list(sec_org.grantapplication_set.values_list('pk', flat=True)) sec_drafts = list(sec_org.draftgrantapplication_set.values_list('pk', flat=True)) sec_papps = ProjectApp.objects.filter(application__organization_id=sec) self.assert_length(sec_apps, 2) self.assert_length(sec_drafts, 2) self.assert_count(sec_papps, 1) sponsored = SponsoredProgramGrant(organization_id=sec, amount=400) sponsored.save() # create app for primary org app = GrantApplication(organization_id=primary, grant_cycle_id=4, founded='1998', budget_last=300, budget_current=600, amount_requested=99) app.save() papp = ProjectApp(application_id=app.pk, giving_project_id=3) papp.save() gpg = GivingProjectGrant(projectapp_id=papp.pk, amount=199, first_report_due='2017-01-03') gpg.save() url = reverse('sjfnw.grants.views.merge_orgs', kwargs={'id_a': sec, 'id_b': primary}) post_data = {'primary': primary} res = self.client.post(url, post_data, follow=True) self.assertEqual(res.status_code, 200) self.assertTemplateUsed(res, 'admin/change_form.html') self.assert_message(res, 'Merge successful. Redirected to new organization page') apps = GrantApplication.objects.filter(organization_id=primary) drafts = DraftGrantApplication.objects.filter(organization_id=primary) papps = ProjectApp.objects.filter(application__organization_id=primary) sponsored = SponsoredProgramGrant.objects.filter(organization_id=primary) self.assert_length(apps, 3) self.assert_length(drafts, 2) self.assert_count(papps, 2) self.assert_count(sponsored, 1)
def test_merge_both_have_objs(self): primary = 1 sec = 2 sec_org = Organization.objects.get(pk=sec) # get draft & app IDs that were associated with secondary org sec_apps = list(sec_org.grantapplication_set.values_list('pk', flat=True)) sec_drafts = list(sec_org.draftgrantapplication_set.values_list('pk', flat=True)) sec_papps = ProjectApp.objects.filter(application__organization_id=sec) self.assert_length(sec_apps, 2) self.assert_length(sec_drafts, 2) self.assert_count(sec_papps, 1) sponsored = SponsoredProgramGrant(organization_id=sec, amount=400) sponsored.save() # create app for primary org app = GrantApplication(organization_id=primary, grant_cycle_id=4, founded='1998', budget_last=300, budget_current=600, amount_requested=99) app.save() papp = ProjectApp(application_id=app.pk, giving_project_id=3) papp.save() gpg = GivingProjectGrant(projectapp_id=papp.pk, amount=199, first_yer_due='2017-01-03') gpg.save() url = reverse('sjfnw.grants.views.merge_orgs', kwargs={'id_a': sec, 'id_b': primary}) post_data = {'primary': primary} res = self.client.post(url, post_data, follow=True) self.assertEqual(res.status_code, 200) self.assertTemplateUsed(res, 'admin/change_form.html') self.assert_message(res, 'Merge successful. Redirected to new organization page') apps = GrantApplication.objects.filter(organization_id=primary) drafts = DraftGrantApplication.objects.filter(organization_id=primary) papps = ProjectApp.objects.filter(application__organization_id=primary) sponsored = SponsoredProgramGrant.objects.filter(organization_id=primary) self.assert_length(apps, 3) self.assert_length(drafts, 2) self.assert_count(papps, 2) self.assert_count(sponsored, 1)