def test_donors_many_filter(self): """Check that filtering on multiple donors returns expected result""" donor_1 = DonorFactory() donor_2 = DonorFactory() grant_number_1 = "G123" grant_number_2 = "G124" GrantFactory( donor=donor_1, name=grant_number_1, ) GrantFactory( donor=donor_2, name=grant_number_2, ) FundsReservationItemFactory(fund_reservation=self.fr_1, grant_number=grant_number_1) FundsReservationItemFactory(fund_reservation=self.fr_2, grant_number=grant_number_2) FundsReservationHeaderFactory() data = { "values": ",".join([self.fr_1.fr_number, self.fr_2.fr_number]), "donors": ",".join([str(donor_1.pk), str(donor_2.pk)]), } status_code, result = self.run_request(data) self.assertEqual(status_code, status.HTTP_200_OK) self.assertEqual(len(result['frs']), 2)
def test_grant(self): donor = DonorFactory.build(name='xyz') grant = GrantFactory.build(donor=donor, name='R\xe4dda Barnen') self.assertEqual(str(grant), 'xyz: R\xe4dda Barnen') donor = DonorFactory.build(name='xyz') grant = GrantFactory.build(donor=donor, name='R\xe4dda Barnen') self.assertEqual(str(grant), 'xyz: R\xe4dda Barnen') donor = DonorFactory.build(name='R\xe4dda Barnen') grant = GrantFactory.build(donor=donor, name='xyz') self.assertEqual(str(grant), 'R\xe4dda Barnen: xyz')
def test_grant_donors_mismatch(self): """Check that filtering on donors and grant not related to donor, returns 400 """ donor = DonorFactory() GrantFactory(donor=donor, ) grant_number = "G123" grant = GrantFactory(name=grant_number, ) FundsReservationItemFactory(fund_reservation=self.fr_1, grant_number=grant_number) data = { "values": self.fr_1.fr_number, "grants": grant.pk, "donors": donor.pk, } status_code, result = self.run_request(data) self.assertEqual(status_code, status.HTTP_400_BAD_REQUEST) self.assertIn( 'please make sure to select FRs that relate to the PD/SSFA Partner', result['error'])
def test_grants_filter(self): """Check that filtering on grant returns expected result""" grant_number = "G123" grant = GrantFactory(name=grant_number) FundsReservationItemFactory(fund_reservation=self.fr_1, grant_number=grant_number) data = { "values": self.fr_1.fr_number, "grants": grant.pk, } status_code, result = self.run_request(data) self.assertEqual(status_code, status.HTTP_200_OK) self.assertEqual(len(result['frs']), 1)
def test_grants_filter_invalid(self): """Check that filtering on invalid grant returns 400""" grant_number = "G123" GrantFactory(name=grant_number) FundsReservationItemFactory(fund_reservation=self.fr_1, grant_number=grant_number) data = { "values": self.fr_1.fr_number, "grants": "404", } status_code, result = self.run_request(data) self.assertEqual(status_code, status.HTTP_400_BAD_REQUEST) self.assertIn( 'please make sure to select FRs that relate to the PD/SSFA Partner', result['error'])
def test_donors_filter(self): """Check that filtering on donor returns expected result""" donor = DonorFactory() grant_number = "G123" GrantFactory( donor=donor, name=grant_number, ) FundsReservationItemFactory(fund_reservation=self.fr_1, grant_number=grant_number) data = { "values": self.fr_1.fr_number, "donors": donor.pk, } status_code, result = self.run_request(data) self.assertEqual(status_code, status.HTTP_200_OK) self.assertEqual(len(result['frs']), 1)
def setUp(self): super().setUp() self.unicef_staff = UserFactory(is_staff=True) self.donor = DonorFactory() self.grant = GrantFactory(donor=self.donor)
def setUp(self): super(TestDonorExportList, self).setUp() self.unicef_staff = UserFactory(is_staff=True) self.donor = DonorFactory() self.grant = GrantFactory(donor=self.donor)
def setUp(self): super(TestGrantExportList, self).setUp() self.unicef_staff = UserFactory(is_staff=True) self.grant = GrantFactory()
def setUpTestData(cls): cls.grant = GrantFactory()