Example #1
0
    def setUp(self):
        self.user = UserFactory()
        self.unicef_staff = UserFactory(is_staff=True)
        self.workplan = WorkplanFactory()
        self.comment = CommentFactory(author=self.user, workplan=self.workplan)

        self.workplan_project = WorkplanProjectFactory(workplan=self.workplan)
        self.labels = [LabelFactory() for x in xrange(3)]

        self.result_type = ResultType.objects.get(id=random.choice([1, 2, 3]))
        self.result = ResultFactory(result_type=self.result_type,
                                    result_structure=ResultStructureFactory())

        self.resultworkplanproperty = ResultWorkplanPropertyFactory(
            workplan=self.workplan, result=self.result, labels=self.labels)
        self.extra_label = LabelFactory()
        self.user2 = UserFactory()

        self.comment2_obj = CommentFactory(author=self.user,
                                           text='foobar',
                                           workplan=self.workplan)
        data = {'tagged_users': [self.user.id]}
        response = self.forced_auth_req('patch',
                                        '/api/comments/{}/'.format(
                                            self.comment2_obj.id),
                                        data=data,
                                        user=self.unicef_staff)
        self.comment2 = response.data
Example #2
0
    def setUp(self):
        self.unicef_staff = UserFactory(is_staff=True)
        self.partner = PartnerFactory()
        agreement = AgreementFactory(partner=self.partner)
        self.intervention = PartnershipFactory(partner=self.partner,
                                               agreement=agreement)
        assert self.partner == self.intervention.partner

        self.result_type = ResultType.objects.get(id=1)
        self.result = ResultFactory(result_type=self.result_type,
                                    result_structure=ResultStructureFactory())
        self.resultchain = ResultChain.objects.create(
            result=self.result,
            result_type=self.result_type,
            partnership=self.intervention,
        )
        self.pcasector = PCASector.objects.create(
            pca=self.intervention,
            sector=Sector.objects.create(name="Sector 1"))
        self.partnership_budget = PartnershipBudget.objects.create(
            partnership=self.intervention, unicef_cash=100)
        self.grant = Grant.objects.create(
            donor=Donor.objects.create(name="Donor 1"), name="Grant 1")
        self.pcagrant = PCAGrant.objects.create(partnership=self.intervention,
                                                grant=self.grant,
                                                funds=100)
        self.amendment = AmendmentLog.objects.create(
            partnership=self.intervention,
            type="Cost",
        )
        self.location = GwPCALocation.objects.create(
            pca=self.intervention, location=LocationFactory())
Example #3
0
 def test_create_user(self):
     user = UserFactory(
         profile__job_title='Chief Tea Maker'
     )
     self.assertTrue(
         'Chief Tea Maker',
         user.profile.job_title
     )
Example #4
0
 def test_approve_trip_with_TA(self):
     """
     Test that if a supervisor approves a trip and TA is selected, and email
     is sent to the programme assistant
     """
     self.trip.status = Trip.APPROVED
     self.trip.ta_required = True
     self.trip.approved_by_supervisor = True
     self.trip.date_supervisor_approved = datetime.now()
     self.trip.programme_assistant = UserFactory()
     self.trip.budget_owner = UserFactory()
     self.trip.approved_email_sent = True
     self.trip.save()
     self.assertEqual(Trip.APPROVED, self.trip.status)
     self.assertEqual(len(mail.outbox), 1)
     # Now test the email is correct for this action
     self.assertTrue(
         self.trip.programme_assistant.first_name in mail.outbox[0].subject)
Example #5
0
 def setUp(self):
     super(TestModelExport, self).setUp()
     self.unicef_staff = UserFactory(is_staff=True)
     self.partner = PartnerFactory()
     self.agreement = AgreementFactory(partner=self.partner)
     # This is here to test partner scoping
     AgreementFactory()
     self.intervention = PartnershipFactory(partner=self.partner,
                                            agreement=self.agreement)
     self.government_intervention = GovernmentInterventionFactory(
         partner=self.partner)
Example #6
0
 def test_approve_trip_with_Vision_Approver(self):
     """
     Test that if a supervisor approves a trip and TA is selected, and email
     is sent to the programme assistant
     """
     self.trip.status = Trip.APPROVED
     self.trip.ta_drafted = True
     self.trip.approved_by_supervisor = True
     self.trip.date_supervisor_approved = datetime.now()
     self.trip.vision_approver = UserFactory()
     self.trip.programme_assistant = UserFactory()
     self.trip.approved_email_sent = True
     self.trip.save()
     self.assertEqual(Trip.APPROVED, self.trip.status)
     self.assertEqual(len(mail.outbox), 1)
     # Now test the email is correct for this action
     self.assertTrue('Travel Authorization' in mail.outbox[0].subject)
     self.assertTrue('VISION' in mail.outbox[0].body)
     self.assertTrue(self.trip.vision_approver.email in mail.outbox[0].to)
     self.assertTrue(
         self.trip.vision_approver.first_name in mail.outbox[0].body)
Example #7
0
    def setUp(self):
        self.unicef_staff = UserFactory(is_staff=True)
        self.result_type = ResultType.objects.get(id=random.choice([1, 2, 3]))
        self.workplan = WorkplanFactory()
        self.result1 = ResultFactory(result_type=self.result_type,
                                     result_structure=ResultStructureFactory())
        self.resultworkplanproperty = ResultWorkplanPropertyFactory(
            workplan=self.workplan, result=self.result1)

        # Additional data to use in tests
        self.location1 = LocationFactory()
        self.location3 = LocationFactory()
        self.section1 = SectionFactory()
        self.section3 = SectionFactory()
Example #8
0
    def setUp(self):
        self.supervisor = UserFactory()
        self.trip = TripFactory(
            owner__first_name='Fred',
            owner__last_name='Test',
            purpose_of_travel='To test some trips',
            supervisor=self.supervisor,
            travel_type=Trip.MEETING,
        )
        self.trip.owner.is_staff = True
        self.trip.owner.save()
        self.user = self.trip.owner

        self.client.login(
            username=self.trip.owner.username,
            password='******'
        )
Example #9
0
    def test_submit_trip_international(self):
        """
        Test that when an international trip is submitted and approved by supervisor,
        the rep is informed that they must approve
        """
        self.trip.status = Trip.SUBMITTED
        self.trip.international_travel = True
        self.trip.approved_by_supervisor = True
        self.trip.representative = UserFactory()
        self.trip.save()
        self.assertEqual(Trip.SUBMITTED, self.trip.status)
        self.assertEqual(len(mail.outbox), 3)

        # Now test the email is correct for this action
        self.assertTrue('Approval' in mail.outbox[1].subject)
        self.assertTrue('representative approval' in mail.outbox[1].body)
        self.assertTrue(self.trip.representative.email in mail.outbox[1].to)
        self.assertTrue(self.trip.owner.email in mail.outbox[1].to)
Example #10
0
    def test_approve_trip_with_Travel_Assistant(self):
        """
        Test that if a supervisor approves a trip and travel assistant is selected,
        an email is sent to the travel assistant
        """
        self.trip.status = Trip.APPROVED
        self.trip.travel_assistant = UserFactory()
        self.trip.approved_by_supervisor = True
        self.trip.date_supervisor_approved = datetime.now()
        self.trip.approved_email_sent = True
        self.trip.save()
        self.assertEqual(Trip.APPROVED, self.trip.status)
        self.assertEqual(len(mail.outbox), 1)

        # Now test the email is correct for this action
        self.assertTrue('travel' in mail.outbox[0].body)
        self.assertTrue(self.trip.travel_assistant.email in mail.outbox[0].to)
        self.assertTrue(
            self.trip.travel_assistant.first_name in mail.outbox[0].body)
Example #11
0
 def setUp(self):
     self.unicef_staff = UserFactory(is_staff=True)
     self.partner = PartnerFactory()
Example #12
0
 def setUp(self):
     self.unicef_staff = UserFactory(is_staff=True)
Example #13
0
 def setUp(self):
     self.unicef_staff = UserFactory(is_staff=True)
     self.locations = [LocationFactory() for x in xrange(5)]