Exemplo n.º 1
0
 def setUpTestData(cls):
     cls.unicef_staff = UserFactory(is_staff=True)
     cls.intervention = InterventionFactory()
     cls.result_link = InterventionResultLinkFactory()
     cls.lower_result = LowerResultFactory(
         name="LL Name",
         result_link=cls.result_link,
     )
     cls.indicator = IndicatorBlueprintFactory()
     AppliedIndicatorFactory(
         context_code="CC321",
         indicator=cls.indicator,
         lower_result=LowerResultFactory(name="LL Name", result_link=cls.result_link),
         cluster_name='ABC',
     )
     AppliedIndicatorFactory(
         context_code="CC321",
         indicator=cls.indicator,
         lower_result=LowerResultFactory(name="LL Name", result_link=cls.result_link),
         cluster_name='XYZ',
     )
     AppliedIndicatorFactory(
         context_code="CC321",
         indicator=cls.indicator,
         lower_result=LowerResultFactory(name="LL Name", result_link=cls.result_link),
         cluster_name='XYZ',
     )
     AppliedIndicatorFactory(
         context_code="CC321",
         indicator=cls.indicator,
         lower_result=LowerResultFactory(name="LL Name", result_link=cls.result_link),
     )
     cls.url = reverse("reports:cluster")
Exemplo n.º 2
0
    def test_lower_result(self):
        instance = LowerResultFactory.build(name='xyz', code='xyz')
        self.assertEqual(str(instance), u'xyz: xyz')

        instance = LowerResultFactory.build(name=u'\xccsland', code='xyz')
        self.assertEqual(str(instance), u'xyz: \xccsland')

        instance = LowerResultFactory.build(name=u'\xccsland', code=u'xyz')
        self.assertEqual(str(instance), u'xyz: \xccsland')
Exemplo n.º 3
0
 def setUpTestData(cls):
     cls.unicef_staff = UserFactory(is_staff=True)
     cls.result_link = InterventionResultLinkFactory()
     cls.lower_result = LowerResultFactory(result_link=cls.result_link)
     cls.indicator = IndicatorBlueprintFactory()
     cls.applied = AppliedIndicatorFactory(indicator=cls.indicator,
                                           lower_result=cls.lower_result)
Exemplo n.º 4
0
 def setUp(self):
     self.lower_result = LowerResultFactory(
         code="C123",
         result_link=self.result_link,
     )
     self.data = {
         "name": "LL Name",
         "code": self.lower_result.code,
     }
Exemplo n.º 5
0
 def setUpTestData(cls):
     cls.unicef_staff = UserFactory(is_staff=True)
     cls.url = reverse("reports:lower-results")
     cls.intervention = InterventionFactory()
     cls.result_link = InterventionResultLinkFactory(
         intervention=cls.intervention, )
     cls.lower_result = LowerResultFactory(
         name="LL Name",
         result_link=cls.result_link,
     )
Exemplo n.º 6
0
 def setUpTestData(cls):
     cls.intervention = InterventionFactory(
         start=datetime.date(2001, 1, 1),
         in_amendment=True,
     )
     cls.result_link = InterventionResultLinkFactory(
         intervention=cls.intervention)
     cls.lower_result = LowerResultFactory(result_link=cls.result_link)
     cls.indicator = AppliedIndicatorFactory(lower_result=cls.lower_result)
     cls.context = {"intervention": cls.intervention}
Exemplo n.º 7
0
 def setUpTestData(cls):
     cls.section = SectorFactory()
     cls.intervention = InterventionFactory()
     cls.result_link = InterventionResultLinkFactory(
         intervention=cls.intervention, )
     cls.lower_result = LowerResultFactory(result_link=cls.result_link, )
     cls.applied_indicator = AppliedIndicatorFactory(
         lower_result=cls.lower_result, )
     cls.location = LocationFactory()
     cls.indicator = IndicatorBlueprintFactory()
Exemplo n.º 8
0
 def test_update(self):
     lower_result = LowerResultFactory(name="New",
                                       result_link=self.result_link)
     lower_result_qs = LowerResult.objects.filter(name="LL Name")
     self.assertFalse(lower_result_qs.exists())
     serializer = LowerResultCUSerializer(data=self.data)
     self.assertTrue(serializer.is_valid())
     lower_result_updated = serializer.update(lower_result,
                                              serializer.validated_data)
     self.assertIsInstance(lower_result_updated, LowerResult)
     self.assertEqual(lower_result_updated.name, "LL Name")
     self.assertTrue(lower_result_qs.exists())
Exemplo n.º 9
0
 def test_validation_pd_has_no_start(self):
     intervention = InterventionFactory(in_amendment=True)
     result_link = InterventionResultLinkFactory(intervention=intervention)
     lower_result = LowerResultFactory(result_link=result_link)
     AppliedIndicatorFactory(lower_result=lower_result)
     data = {
         "report_type": ReportingRequirement.TYPE_QPR,
         "reporting_requirements": []
     }
     serializer = InterventionReportingRequirementCreateSerializer(
         data=data, context={"intervention": intervention})
     self.assertFalse(serializer.is_valid())
     self.assertEqual(serializer.errors['non_field_errors'],
                      ['PD needs to have a start date.'])
Exemplo n.º 10
0
 def test_validation_pd_status(self):
     intervention = InterventionFactory(start=datetime.date(2001, 1, 1),
                                        status=Intervention.CLOSED)
     result_link = InterventionResultLinkFactory(intervention=intervention)
     lower_result = LowerResultFactory(result_link=result_link)
     AppliedIndicatorFactory(lower_result=lower_result)
     data = {
         "report_type": ReportingRequirement.TYPE_QPR,
         "reporting_requirements": []
     }
     serializer = InterventionReportingRequirementCreateSerializer(
         data=data, context={"intervention": intervention})
     self.assertFalse(serializer.is_valid())
     self.assertEqual(
         serializer.errors['non_field_errors'],
         ['Changes not allowed when PD not in amendment state.'])
Exemplo n.º 11
0
 def setUp(self):
     self.indicator = IndicatorBlueprintFactory()
     self.intervention = InterventionFactory(status=Intervention.ACTIVE)
     self.result_link = InterventionResultLinkFactory(
         intervention=self.intervention, )
     self.lower_result = LowerResultFactory(result_link=self.result_link, )
     self.applied_indicator = AppliedIndicatorFactory(
         lower_result=self.lower_result,
         target={
             "d": 3,
             "v": 4
         },
     )
     self.intervention.flat_locations.add(self.location)
     self.intervention.sections.add(self.section)
     self.data = {
         "indicator": {
             "title": self.indicator.title
         },
         "lower_result": self.lower_result.pk,
         "locations": [self.location.pk],
         "section": self.section.pk,
     }
Exemplo n.º 12
0
 def setUpTestData(cls):
     cls.unicef_staff = UserFactory(is_staff=True)
     cls.result_link = InterventionResultLinkFactory()
     cls.lower_result = LowerResultFactory(result_link=cls.result_link)
Exemplo n.º 13
0
 def setUp(self):
     self.lower_result = LowerResultFactory(result_link=self.result_link, )
     self.url = reverse("reports:lower-results-del",
                        args=[self.lower_result.pk])
Exemplo n.º 14
0
 def setUpTestData(cls):
     cls.result_link = InterventionResultLinkFactory()
     cls.lower_result = LowerResultFactory(result_link=cls.result_link)