コード例 #1
0
    def test_issue_found(self):
        """Check that is country programme for intervention does not
        match result country programme then issue is created"""
        qs_issue = FlaggedIssue.objects.filter(
            issue_id="pd_outputs_wrong"
        )
        start_date = datetime.date(2001, 1, 1)
        end_date = datetime.date(2001, 12, 31)
        country = CountryProgrammeFactory(
            from_date=start_date,
            to_date=end_date,
        )
        intervention = InterventionFactory(
            country_programme=country,
            start=start_date,
        )
        result = ResultFactory(country_programme=CountryProgrammeFactory())
        InterventionResultLink.objects.create(
            intervention=intervention,
            cp_output=result,
        )
        self.assertNotEqual(
            intervention.country_programme,
            result.country_programme
        )

        self.assertFalse(qs_issue.exists())
        checks.bootstrap_checks(default_is_active=True)
        checks.run_all_checks()
        self.assertTrue(qs_issue.exists())
        issue = qs_issue.first()
        self.assertIn("has wrongly mapped outputs", issue.message)
コード例 #2
0
    def test_no_issue(self):
        """Check that valida interventions results in no issue"""
        qs_issue = FlaggedIssue.objects.filter(
            issue_id="pd_outputs_wrong"
        )
        start_date = datetime.date(2001, 1, 1)
        end_date = datetime.date(2001, 12, 31)
        country = CountryProgrammeFactory(
            from_date=start_date,
            to_date=end_date,
        )
        intervention = InterventionFactory(
            country_programme=country,
            start=start_date,
        )
        result = ResultFactory(country_programme=country)
        InterventionResultLink.objects.create(
            intervention=intervention,
            cp_output=result,
        )
        self.assertEqual(
            intervention.country_programme,
            result.country_programme
        )

        self.assertFalse(qs_issue.exists())
        checks.bootstrap_checks(default_is_active=True)
        checks.run_all_checks()
        self.assertFalse(qs_issue.exists())
コード例 #3
0
 def test_prp_api_performance(self):
     EXPECTED_QUERIES = 25
     with self.assertNumQueries(EXPECTED_QUERIES):
         self.run_prp_v1(user=self.unicef_staff, method='get')
     # make a bunch more stuff, make sure queries don't go up.
     intervention = InterventionFactory(agreement=self.agreement,
                                        title='New Intervention')
     result = ResultFactory(name='Another Result')
     result_link = InterventionResultLink.objects.create(
         intervention=intervention, cp_output=result)
     lower_result = LowerResult.objects.create(result_link=result_link,
                                               name='Lower Result 1')
     indicator_blueprint = IndicatorBlueprint.objects.create(
         title='The Blueprint')
     applied_indicator = AppliedIndicator.objects.create(
         indicator=indicator_blueprint,
         lower_result=lower_result,
     )
     applied_indicator.locations.add(
         LocationFactory(name='A Location',
                         gateway=GatewayTypeFactory(name='Another Gateway'),
                         p_code='a-p-code'))
     applied_indicator.disaggregation.create(name='Another Disaggregation')
     with self.assertNumQueries(EXPECTED_QUERIES):
         self.run_prp_v1(user=self.unicef_staff, method='get')
コード例 #4
0
    def test_no_interventions(self):
        """If intervention does not fit in with Country Programmes
        then no issues raised
        """
        qs_issue = FlaggedIssue.objects.filter(
            issue_id="pd_outputs_wrong"
        )
        start_date = datetime.date(2001, 1, 1)
        end_date = datetime.date(2001, 12, 31)
        country = CountryProgrammeFactory(
            from_date=start_date,
            to_date=end_date,
        )
        intervention = InterventionFactory(
            country_programme=country,
            start=start_date - datetime.timedelta(days=1),
        )
        result = ResultFactory(country_programme=CountryProgrammeFactory())
        InterventionResultLink.objects.create(
            intervention=intervention,
            cp_output=result,
        )
        self.assertNotEqual(
            intervention.country_programme,
            result.country_programme
        )

        self.assertFalse(qs_issue.exists())
        checks.bootstrap_checks(default_is_active=True)
        checks.run_all_checks()
        self.assertFalse(qs_issue.exists())
コード例 #5
0
ファイル: test_models.py プロジェクト: alhadheri/etools
 def test_result_name_no_code(self):
     result_type = ResultTypeFactory(name="RType")
     result = ResultFactory(
         code="",
         result_type=result_type,
         name="Result"
     )
     self.assertEqual(result.result_name, " RType: Result")
コード例 #6
0
    def setUpTestData(cls):
        cls.user = UserFactory(is_staff=True)  # UNICEF staff user
        cls.result_type = ResultTypeFactory(name=ResultType.OUTPUT)

        today = datetime.date.today()
        cls.country_programme = CountryProgrammeFactory(
            wbs='0000/A0/01',
            from_date=datetime.date(today.year - 1, 1, 1),
            to_date=datetime.date(today.year + 1, 1, 1))

        cls.result1 = ResultFactory(
            result_type=cls.result_type,
            country_programme=cls.country_programme,
        )

        cls.result2 = ResultFactory(result_type=cls.result_type,
                                    country_programme=cls.country_programme)
        cls.url = reverse('reports:report-result-list')
コード例 #7
0
ファイル: test_api_partners.py プロジェクト: azizur77/etools
    def setUpTestData(cls):
        cls.unicef_staff = UserFactory(is_staff=True)
        cls.partner = PartnerFactory(
            partner_type=PartnerType.CIVIL_SOCIETY_ORGANIZATION,
            cso_type="International",
            hidden=False,
            vendor_number="DDD",
            short_name="Short name",
        )

        report = "report.pdf"
        cls.assessment1 = Assessment.objects.create(partner=cls.partner,
                                                    type="Micro Assessment")
        cls.assessment2 = Assessment.objects.create(
            partner=cls.partner,
            type="Micro Assessment",
            report=report,
            completed_date=datetime.date.today())

        cls.partner_gov = PartnerFactory(partner_type=PartnerType.GOVERNMENT)

        agreement = AgreementFactory(
            partner=cls.partner, signed_by_unicef_date=datetime.date.today())

        cls.intervention = InterventionFactory(agreement=agreement)
        cls.output_res_type = ResultTypeFactory(name=ResultType.OUTPUT)

        cls.result = ResultFactory(result_type=cls.output_res_type, )

        cls.partnership_budget = InterventionBudget.objects.create(
            intervention=cls.intervention,
            unicef_cash=100,
            unicef_cash_local=10,
            partner_contribution=200,
            partner_contribution_local=20,
            in_kind_amount_local=10,
        )
        cls.amendment = InterventionAmendment.objects.create(
            intervention=cls.intervention,
            types=[InterventionAmendment.RESULTS])

        cls.cp = CountryProgrammeFactory(__sequence=10)
        cls.cp_output = ResultFactory(result_type=cls.output_res_type)
コード例 #8
0
 def test_update_activities_exists(self):
     """If Result (of type activity) exists with WBS value, and attributes
     have NOT changed then no update
     """
     ResultFactory(name="New",
                   wbs="R1",
                   result_type=self.result_type_activity)
     self.data["activities"] = {"R1": {"name": "New"}}
     self.adapter.data = self.data
     total_data, total_updated, length = self.adapter.update_activities()
     self.assertEqual(total_data, 1)
     self.assertEqual(total_updated, 0)
     self.assertEqual(length, 0)
コード例 #9
0
ファイル: test_synchronizers.py プロジェクト: azizur77/etools
 def test_update_all_exist(self):
     """Check response from all update which is a wrapper method
     that calls;
     - update_cps
     - update_outcomes
     - update_outputs
     - update_activities
     """
     CountryProgrammeFactory(name="New CP", wbs="C1")
     ResultFactory(
         name="New Outcome",
         wbs="R1",
         result_type=self.result_type_outcome
     )
     ResultFactory(
         name="New Output",
         wbs="R2",
         result_type=self.result_type_output
     )
     ResultFactory(
         name="New Activity",
         wbs="R3",
         result_type=self.result_type_activity
     )
     self.data["cps"] = {"C1": {"name": "New CP"}}
     self.data["outcomes"] = {"R1": {"name": "New Outcome"}}
     self.data["outputs"] = {"R2": {"name": "New Output"}}
     self.data["activities"] = {"R3": {"name": "New Activity"}}
     self.adapter.data = self.data
     result = self.adapter.update()
     self.assertEqual(
         result["details"],
         "CPs updated: Total 1, Updated 0, New 0\n"
         "Outcomes updated: Total 1, Updated 0, New 0\n"
         "Outputs updated: Total 1, Updated 0, New 0\n"
         "Activities updated: Total 1, Updated 0, New 0"
     )
     self.assertEqual(result["total_records"], 4)
     self.assertEqual(result["processed"], 0)
コード例 #10
0
 def test_update_activities_updated(self):
     """If Result (of type activity) exists with WBS value, and attributes
     have changed then update
     """
     result = ResultFactory(name="New",
                            wbs="R1",
                            result_type=self.result_type_activity)
     self.data["activities"] = {"R1": {"name": "Changed"}}
     self.adapter.data = self.data
     total_data, total_updated, length = self.adapter.update_activities()
     self.assertEqual(total_data, 1)
     self.assertEqual(total_updated, 1)
     self.assertEqual(length, 0)
     result_updated = Result.objects.get(pk=result.pk)
     self.assertEqual(result_updated.name, "Changed")
コード例 #11
0
    def test_no_country_programme(self):
        """Check that if intervention has no country programme
        the intervention is ignored during the check
        """
        qs_issue = FlaggedIssue.objects.filter(issue_id="pd_outputs_wrong")
        intervention = InterventionFactory()
        result = ResultFactory(country_programme=CountryProgrammeFactory())
        InterventionResultLink.objects.create(
            intervention=intervention,
            cp_output=result,
        )
        self.assertIsNone(intervention.country_programme)
        self.assertNotEqual(intervention.country_programme,
                            result.country_programme)

        self.assertFalse(qs_issue.exists())
        checks.bootstrap_checks(default_is_active=True)
        checks.run_all_checks()
        self.assertFalse(qs_issue.exists())
コード例 #12
0
ファイル: test_synchronizers.py プロジェクト: azizur77/etools
 def test_process_indicators_create(self):
     """Check that indicator is created"""
     ResultFactory(
         result_type=self.result_type_output,
         wbs="1234/56/78/90A/BCD"
     )
     indicator_qs = Indicator.objects.filter(name="NAME")
     self.assertFalse(indicator_qs.exists())
     response = self.adapter.process_indicators([self.data])
     self.assertEqual(response, {
         "details": "Created Skipped 0\n"
         "Updated Skipped 0\n"
         "Created 1\n"
         "Indicators Updated to Active 0\n"
         "Indicators Updated to Inactive 0\n"
         "Updated 0",
         "total_records": 1,
         "processed": 1
     })
     self.assertTrue(indicator_qs.exists())
コード例 #13
0
 def setUpTestData(cls):
     cls.unicef_staff = UserFactory(is_staff=True)
     cls.result = ResultFactory()
     cls.indicator = IndicatorFactory(result=cls.result)
     cls.url = reverse("reports:result-indicator-list",
                       args=[cls.result.pk])
コード例 #14
0
    def test_intervention_location_export(self):
        # First intervention was already created for us in setUpTestData
        partner_name = self.intervention.agreement.partner.name

        # Assign known dates that we can test for in the output later on
        self.intervention.start = datetime.date(2013, 1, 6)
        self.intervention.end = datetime.date(2013, 3, 20)
        self.intervention.save()

        # Some locations
        self.intervention.flat_locations.add(
            LocationFactory(name='Location 0'),
            LocationFactory(name='Location 1'))

        # Some sections
        sec = SectorFactory(name='Sector 0')
        sec1 = SectorFactory(name='Sector 1')
        self.intervention.sections.add(sec, sec1)

        # Some focal points
        self.intervention.unicef_focal_points.add(
            UserFactory(first_name='Jack', last_name='Bennie'),
            UserFactory(first_name='Phil', last_name='Silver'))

        # Some results
        InterventionResultLinkFactory(cp_output=ResultFactory(sector=sec1,
                                                              name='Result A'),
                                      intervention=self.intervention)
        InterventionResultLinkFactory(cp_output=ResultFactory(sector=sec1,
                                                              name='Result B'),
                                      intervention=self.intervention)

        # Another intervention, with no locations
        self.intervention2 = InterventionFactory(agreement=AgreementFactory(
            partner=PartnerFactory(name='Partner 2')))
        # Sections
        sec2 = SectorFactory(name='Sector 2')
        sec3 = SectorFactory(name='Sector 3')
        self.intervention2.sections.add(sec2, sec3)
        # Results
        InterventionResultLinkFactory(cp_output=ResultFactory(sector=sec2,
                                                              name='Result C'),
                                      intervention=self.intervention2)
        InterventionResultLinkFactory(cp_output=ResultFactory(sector=sec3,
                                                              name='Result D'),
                                      intervention=self.intervention2)

        # Intervention with no sectors
        self.intervention3 = InterventionFactory(agreement=AgreementFactory(
            partner=PartnerFactory(name='Partner 3')))
        self.intervention3.flat_locations.add(
            LocationFactory(name='Location 2'))
        InterventionResultLinkFactory(
            intervention=self.intervention3,
            cp_output=ResultFactory(name='Result Fred'))

        self.url = reverse('partners_api:intervention-locations-list', )

        response = self.forced_auth_req(
            'get',
            self.url,
            user=self.unicef_staff,
            data={"format": "csv"},
        )
        self.assertEqual(200,
                         response.status_code,
                         msg=response.content.decode('utf-8'))
        result = response.content.decode('utf-8')

        today = datetime.date.today()
        self.assertEqual(
            f'attachment;filename={today.year}_{today.month}_{today.day}_TST_Interventions.csv',
            response['Content-Disposition'],
        )

        # Leave this here to easily uncomment for debugging.
        # print("RESULT:")
        # for line in result.split('\r\n'):
        #     print('f' + repr(line + '\r\n'))

        agreement_number_1 = self.intervention.agreement.agreement_number
        agreement_number_2 = self.intervention2.agreement.agreement_number
        agreement_number_3 = self.intervention3.agreement.agreement_number
        self.assertEqual(
            f'Partner,PD Ref Number,Partnership,Status,Location,Section,CP output,Start Date,End Date,Name of UNICEF Focal Point,Hyperlink\r\n'
            f'{partner_name},{self.intervention.number},{agreement_number_1},draft,Location 0,Sector 0,"Result A, Result B",2013-01-06,2013-03-20,"Jack Bennie, Phil Silver",https://testserver/pmp/interventions/{self.intervention.id}/details/\r\n'
            f'{partner_name},{self.intervention.number},{agreement_number_1},draft,Location 1,Sector 0,"Result A, Result B",2013-01-06,2013-03-20,"Jack Bennie, Phil Silver",https://testserver/pmp/interventions/{self.intervention.id}/details/\r\n'
            f'{partner_name},{self.intervention.number},{agreement_number_1},draft,Location 0,Sector 1,"Result A, Result B",2013-01-06,2013-03-20,"Jack Bennie, Phil Silver",https://testserver/pmp/interventions/{self.intervention.id}/details/\r\n'
            f'{partner_name},{self.intervention.number},{agreement_number_1},draft,Location 1,Sector 1,"Result A, Result B",2013-01-06,2013-03-20,"Jack Bennie, Phil Silver",https://testserver/pmp/interventions/{self.intervention.id}/details/\r\n'
            f'Partner 2,{self.intervention2.number},{agreement_number_2},draft,,Sector 2,"Result C, Result D",,,,https://testserver/pmp/interventions/{self.intervention2.id}/details/\r\n'
            f'Partner 2,{self.intervention2.number},{agreement_number_2},draft,,Sector 3,"Result C, Result D",,,,https://testserver/pmp/interventions/{self.intervention2.id}/details/\r\n'
            f'Partner 3,{self.intervention3.number},{agreement_number_3},draft,Location 2,,Result Fred,,,,https://testserver/pmp/interventions/{self.intervention3.id}/details/\r\n',
            result,
        )
コード例 #15
0
ファイル: test_models.py プロジェクト: adi130987/etools
    def test_result(self):
        instance = ResultFactory.build(name='xyz')
        self.assertTrue(str(instance).endswith(u'xyz'))

        instance = ResultFactory.build(name=u'\xccsland')
        self.assertTrue(str(instance).endswith(u'\xccsland'))
コード例 #16
0
ファイル: test_models.py プロジェクト: adi130987/etools
 def test_valid_entry_no(self):
     programme = CountryProgrammeFactory(wbs="WBS")
     result = ResultFactory(wbs="SBW", country_programme=programme)
     self.assertFalse(result.valid_entry())
コード例 #17
0
ファイル: test_models.py プロジェクト: adi130987/etools
 def test_valid_entry_no_wbs(self):
     programme = CountryProgrammeFactory(wbs="WBS")
     result = ResultFactory(country_programme=programme)
     self.assertIsNone(result.valid_entry())
コード例 #18
0
    def test_activity_export(self):
        tz = timezone.get_default_timezone()
        office = OfficeFactory(name='Budapest')
        section_health = SectorFactory(name='Health')
        section_education = SectorFactory(name='Education')

        location_ABC = LocationFactory(name='Location ABC')
        location_345 = LocationFactory(name='Location 345')
        location_111 = LocationFactory(name='Location 111')

        partnership_A1 = InterventionFactory(title='Partnership A1')
        partner = partnership_A1.agreement.partner
        partner.name = 'Partner A'
        partner.save()

        partnership_A2 = InterventionFactory(title='Partnership A2')
        agreement = partnership_A2.agreement
        agreement.partner = partner
        agreement.save()

        partnership_B3 = InterventionFactory(title='Partnership B3')
        partner = partnership_B3.agreement.partner
        partner.name = 'Partner B'
        partner.save()

        partnership_C1 = InterventionFactory(title='Partnership C1')
        partner = partnership_C1.agreement.partner
        partner.name = 'Partner C'
        partner.save()

        # Some results
        result_A11 = ResultFactory(name='Result A11')
        result_A21 = ResultFactory(name='Result A21')

        # set up travels
        user_joe_smith = UserFactory(first_name='Joe',
                                     last_name='Smith')
        user_alice_carter = UserFactory(first_name='Alice',
                                        last_name='Carter')
        user_lenox_lewis = UserFactory(first_name='Lenox',
                                       last_name='Lewis')
        travel_1 = TravelFactory(reference_number='2016/1000',
                                 traveler=user_joe_smith,
                                 office=office,
                                 sector=section_health,
                                 start_date=datetime(2017, 11, 8, tzinfo=tz),
                                 end_date=datetime(2017, 11, 14, tzinfo=tz),
                                 )
        supervisor = UserFactory()
        travel_2 = TravelFactory(reference_number='2016/1211',
                                 supervisor=supervisor,
                                 traveler=user_alice_carter,
                                 office=office,
                                 sector=section_education,
                                 start_date=datetime(2017, 11, 8, tzinfo=tz),
                                 end_date=datetime(2017, 11, 14, tzinfo=tz),
                                 )

        # Do some cleanup
        TravelActivity.objects.all().delete()

        # Create the activities finally
        activity_1 = TravelActivityFactory(travel_type=TravelType.PROGRAMME_MONITORING,
                                           date=datetime(2016, 12, 3, tzinfo=UTC),
                                           result=result_A11,
                                           primary_traveler=user_joe_smith)
        activity_1.travels.add(travel_1)
        activity_1.locations.set([location_ABC, location_345])
        activity_1.partner = partnership_A1.agreement.partner
        activity_1.partnership = partnership_A1
        activity_1.save()

        activity_2 = TravelActivityFactory(travel_type=TravelType.PROGRAMME_MONITORING,
                                           date=datetime(2016, 12, 4, tzinfo=UTC),
                                           result=result_A21,
                                           primary_traveler=user_lenox_lewis)
        activity_2.travels.add(travel_1)
        activity_2.locations.set([location_111])
        activity_2.partner = partnership_A2.agreement.partner
        activity_2.partnership = partnership_A2
        activity_2.save()

        activity_3 = TravelActivityFactory(travel_type=TravelType.MEETING,
                                           date=datetime(2016, 12, 3, tzinfo=UTC),
                                           result=None,
                                           primary_traveler=user_joe_smith)
        activity_3.travels.add(travel_1)
        activity_3.locations.set([location_ABC])
        activity_3.partner = partnership_B3.agreement.partner
        activity_3.partnership = partnership_B3
        activity_3.save()

        activity_4 = TravelActivityFactory(travel_type=TravelType.SPOT_CHECK,
                                           date=datetime(2016, 12, 6, tzinfo=UTC),
                                           result=None,
                                           primary_traveler=user_alice_carter)
        activity_4.travels.add(travel_2)
        activity_4.locations.set([location_111, location_345])
        activity_4.partner = partnership_C1.agreement.partner
        activity_4.partnership = partnership_C1
        activity_4.save()

        with self.assertNumQueries(6):
            response = self.forced_auth_req('get', reverse('t2f:travels:list:activity_export'),
                                            user=self.unicef_staff)
        export_csv = csv.reader(StringIO(response.content.decode('utf-8')))
        rows = [r for r in export_csv]

        self.assertEqual(len(rows), 5)

        # check header
        self.assertEqual(rows[0],
                         ['reference_number',
                          'traveler',
                          'office',
                          'section',
                          'status',
                          'trip_type',
                          'partner',
                          'partnership',
                          'results',
                          'locations',
                          'start_date',
                          'end_date',
                          'is_secondary_traveler',
                          'primary_traveler_name'])

        self.assertEqual(rows[1],
                         ['2016/1000',
                          'Joe Smith',
                          'Budapest',
                          'Health',
                          'planned',
                          'Programmatic Visit',
                          'Partner A',
                          'Partnership A1',
                          'Result A11',
                          'Location 345, Location ABC',
                          '08-Nov-2017',
                          '14-Nov-2017',
                          '',
                          ''])

        self.assertEqual(rows[2],
                         ['2016/1000',
                          'Joe Smith',
                          'Budapest',
                          'Health',
                          'planned',
                          'Programmatic Visit',
                          'Partner A',
                          'Partnership A2',
                          'Result A21',
                          'Location 111',
                          '08-Nov-2017',
                          '14-Nov-2017',
                          'YES',
                          'Lenox Lewis'])

        self.assertEqual(rows[3],
                         ['2016/1000',
                          'Joe Smith',
                          'Budapest',
                          'Health',
                          'planned',
                          'Meeting',
                          'Partner B',
                          'Partnership B3',
                          '',
                          'Location ABC',
                          '08-Nov-2017',
                          '14-Nov-2017',
                          '',
                          ''])

        self.assertEqual(rows[4],
                         ['2016/1211',
                          'Alice Carter',
                          'Budapest',
                          'Education',
                          'planned',
                          'Spot Check',
                          'Partner C',
                          'Partnership C1',
                          '',
                          'Location 111, Location 345',
                          '08-Nov-2017',
                          '14-Nov-2017',
                          '',
                          ''])
コード例 #19
0
def setup_intervention_test_data(test_case,
                                 include_results_and_indicators=False):
    today = datetime.date.today()
    test_case.unicef_staff = UserFactory(is_staff=True)
    test_case.partnership_manager_user = UserFactory(is_staff=True)
    test_case.partnership_manager_user.groups.add(GroupFactory())
    test_case.partner = PartnerFactory(name='Partner 1', vendor_number="VP1")
    test_case.partner1 = PartnerFactory(name='Partner 2')
    test_case.agreement = AgreementFactory(
        partner=test_case.partner, signed_by_unicef_date=datetime.date.today())

    test_case.active_agreement = AgreementFactory(
        partner=test_case.partner1,
        status='active',
        signed_by_unicef_date=datetime.date.today(),
        signed_by_partner_date=datetime.date.today())

    test_case.intervention = InterventionFactory(agreement=test_case.agreement,
                                                 title='Intervention 1')
    test_case.intervention_2 = InterventionFactory(
        agreement=test_case.agreement,
        title='Intervention 2',
        document_type=Intervention.PD,
    )
    test_case.active_intervention = InterventionFactory(
        agreement=test_case.active_agreement,
        title='Active Intervention',
        document_type=Intervention.PD,
        start=today - datetime.timedelta(days=1),
        end=today + datetime.timedelta(days=90),
        status='active',
        signed_by_unicef_date=today - datetime.timedelta(days=1),
        signed_by_partner_date=today - datetime.timedelta(days=1),
        unicef_signatory=test_case.unicef_staff,
        partner_authorized_officer_signatory=test_case.partner1.staff_members.
        all().first())

    test_case.result_type = ResultType.objects.get_or_create(
        name=ResultType.OUTPUT)[0]
    test_case.result = ResultFactory(result_type=test_case.result_type)

    test_case.partnership_budget = InterventionBudget.objects.create(
        intervention=test_case.intervention,
        unicef_cash=10,
        unicef_cash_local=100,
        partner_contribution=20,
        partner_contribution_local=200,
        in_kind_amount_local=10,
    )

    # set up two frs not connected to any interventions
    test_case.fr_1 = FundsReservationHeaderFactory(intervention=None,
                                                   currency='USD')
    test_case.fr_2 = FundsReservationHeaderFactory(intervention=None,
                                                   currency='USD')

    if include_results_and_indicators:
        # setup additional inicator/results
        test_case.result = ResultFactory(name='A Result')
        test_case.result_link = InterventionResultLink.objects.create(
            intervention=test_case.active_intervention,
            cp_output=test_case.result)
        test_case.lower_result = LowerResult.objects.create(
            result_link=test_case.result_link, name='Lower Result 1')
        test_case.indicator_blueprint = IndicatorBlueprint.objects.create(
            title='The Blueprint')
        test_case.applied_indicator = AppliedIndicator.objects.create(
            indicator=test_case.indicator_blueprint,
            lower_result=test_case.lower_result,
        )
        test_case.applied_indicator.locations.add(
            LocationFactory(name='A Location',
                            gateway=GatewayTypeFactory(name='A Gateway'),
                            p_code='a-p-code'))
        test_case.disaggregation = test_case.applied_indicator.disaggregation.create(
            name='A Disaggregation')

    test_case.file_type_attachment = AttachmentFileTypeFactory(
        code="partners_intervention_attachment")
    test_case.file_type_prc = AttachmentFileTypeFactory(
        code="partners_intervention_prc_review")
    test_case.file_type_pd = AttachmentFileTypeFactory(
        code="partners_intervention_signed_pd")
コード例 #20
0
    def setUpTestData(cls):
        cls.unicef_staff = UserFactory(is_staff=True)
        cls.partner = PartnerFactory(
            partner_type=PartnerType.UN_AGENCY,
            vendor_number='Vendor No',
            short_name="Short Name",
            alternate_name="Alternate Name",
            shared_with=["DPKO", "ECA"],
            address="Address 123",
            phone_number="Phone no 1234567",
            email="*****@*****.**",
            rating=PartnerOrganization.RATING_HIGH,
            core_values_assessment_date=datetime.date.today(),
            total_ct_cp=10000,
            total_ct_cy=20000,
            net_ct_cy=100.0,
            reported_cy=300.0,
            total_ct_ytd=400.0,
            deleted_flag=False,
            blocked=False,
            type_of_assessment="Type of Assessment",
            last_assessment_date=datetime.date.today(),
        )
        cls.partnerstaff = PartnerStaffFactory(partner=cls.partner)
        attachment = tempfile.NamedTemporaryFile(suffix=".pdf").name
        cls.agreement = AgreementFactory(
            partner=cls.partner,
            country_programme=CountryProgrammeFactory(wbs="random WBS"),
            attached_agreement=attachment,
            start=datetime.date.today(),
            end=datetime.date.today(),
            signed_by_unicef_date=datetime.date.today(),
            signed_by=cls.unicef_staff,
            signed_by_partner_date=datetime.date.today())
        cls.agreement.authorized_officers.add(cls.partnerstaff)
        cls.agreement.save()
        # This is here to test partner scoping
        AgreementFactory(signed_by_unicef_date=datetime.date.today())
        cls.intervention = InterventionFactory(
            agreement=cls.agreement,
            document_type=Intervention.SHPD,
            status='draft',
            start=datetime.date.today(),
            end=datetime.date.today(),
            submission_date=datetime.date.today(),
            submission_date_prc=datetime.date.today(),
            review_date_prc=datetime.date.today(),
            signed_by_unicef_date=datetime.date.today(),
            signed_by_partner_date=datetime.date.today(),
            unicef_signatory=cls.unicef_staff,
            population_focus="Population focus",
            partner_authorized_officer_signatory=cls.partnerstaff,
            country_programme=cls.agreement.country_programme,
        )
        cls.ib = InterventionBudgetFactory(intervention=cls.intervention,
                                           currency="USD")
        cls.planned_visit = PartnerPlannedVisitsFactory(partner=cls.partner)

        output_res_type, _ = ResultType.objects.get_or_create(name='Output')
        cls.result = ResultFactory(result_type=output_res_type)
        cls.planned_visit = InterventionPlannedVisitsFactory(
            intervention=cls.intervention, )