예제 #1
0
 def test_update_qpr(self):
     """Updating existing qpr reporting requirements"""
     report_type = ReportingRequirement.TYPE_QPR
     requirement = ReportingRequirementFactory(
         intervention=self.intervention,
         report_type=report_type,
         start_date=datetime.date(2001, 1, 3),
         due_date=datetime.date(2001, 4, 15),
     )
     requirement_qs = ReportingRequirement.objects.filter(
         intervention=self.intervention,
         report_type=report_type,
     )
     init_count = requirement_qs.count()
     data = {
         "report_type":
         report_type,
         "reporting_requirements": [{
             "start_date": datetime.date(2001, 1, 1),
             "end_date": datetime.date(2001, 3, 31),
             "due_date": datetime.date(2001, 4, 15),
         }]
     }
     serializer = InterventionReportingRequirementCreateSerializer(
         data=data, context=self.context)
     self.assertTrue(serializer.is_valid())
     serializer.create(serializer.validated_data)
     self.assertEqual(requirement_qs.count(), init_count)
     req_updated = ReportingRequirement.objects.get(pk=requirement.pk)
     self.assertEqual(req_updated.start_date, datetime.date(2001, 1, 1))
     self.assertEqual(req_updated.end_date, datetime.date(2001, 3, 31))
     self.assertEqual(req_updated.due_date, datetime.date(2001, 4, 15))
예제 #2
0
 def test_update_create_hr(self):
     """Updating existing hr reporting requirements and create new"""
     AppliedIndicatorFactory(is_high_frequency=True,
                             lower_result=self.lower_result)
     report_type = ReportingRequirement.TYPE_HR
     requirement = ReportingRequirementFactory(
         intervention=self.intervention,
         report_type=report_type,
         due_date=datetime.date(2001, 4, 15),
     )
     requirement_qs = ReportingRequirement.objects.filter(
         intervention=self.intervention,
         report_type=report_type,
     )
     init_count = requirement_qs.count()
     data = {
         "report_type":
         report_type,
         "reporting_requirements": [{
             "due_date": datetime.date(2001, 4, 15),
         }, {
             "due_date": datetime.date(2001, 6, 15),
         }]
     }
     serializer = InterventionReportingRequirementCreateSerializer(
         data=data, context=self.context)
     self.assertTrue(serializer.is_valid())
     serializer.create(serializer.validated_data)
     self.assertEqual(requirement_qs.count(), init_count + 1)
     req_updated = ReportingRequirement.objects.get(pk=requirement.pk)
     self.assertEqual(req_updated.start_date, None)
     self.assertEqual(req_updated.end_date, req_updated.due_date)
     self.assertEqual(req_updated.due_date, datetime.date(2001, 4, 15))
예제 #3
0
    def test_create_hr(self):
        """Creating new hr reporting requirements

        When none currently existing
        """
        AppliedIndicatorFactory(is_high_frequency=True,
                                lower_result=self.lower_result)
        requirement_qs = ReportingRequirement.objects.filter(
            intervention=self.intervention,
            report_type=ReportingRequirement.TYPE_HR,
        )
        init_count = requirement_qs.count()
        data = {
            "report_type":
            ReportingRequirement.TYPE_HR,
            "reporting_requirements": [{
                "due_date": datetime.date(2001, 4, 15)
            }, {
                "due_date": datetime.date(2001, 5, 15)
            }]
        }
        serializer = InterventionReportingRequirementCreateSerializer(
            data=data, context=self.context)
        self.assertTrue(serializer.is_valid())
        serializer.create(serializer.validated_data)
        self.assertEqual(requirement_qs.count(), init_count + 2)
예제 #4
0
    def test_create_qpr(self):
        """Creating new qpr reporting requirements

        When none currently existing
        """
        requirement_qs = ReportingRequirement.objects.filter(
            intervention=self.intervention,
            report_type=ReportingRequirement.TYPE_QPR,
        )
        init_count = requirement_qs.count()
        data = {
            "report_type":
            ReportingRequirement.TYPE_QPR,
            "reporting_requirements": [{
                "start_date": datetime.date(2001, 1, 1),
                "end_date": datetime.date(2001, 3, 31),
                "due_date": datetime.date(2001, 4, 15),
            }, {
                "start_date": datetime.date(2001, 4, 1),
                "end_date": datetime.date(2001, 5, 31),
                "due_date": datetime.date(2001, 5, 15),
            }]
        }
        serializer = InterventionReportingRequirementCreateSerializer(
            data=data, context=self.context)
        self.assertTrue(serializer.is_valid())
        serializer.create(serializer.validated_data)
        self.assertEqual(requirement_qs.count(), init_count + 2)
    def test_update_create_hr(self):
        """Updating existing hr reporting requirements and create new"""
        AppliedIndicatorFactory(
            is_high_frequency=True,
            lower_result=self.lower_result
        )
        report_type = ReportingRequirement.TYPE_HR
        data = {
            "report_type": report_type,
            "reporting_requirements": [{
                "start_date": datetime.date(2001, 3, 15),
                "due_date": datetime.date(2001, 4, 15),
                "end_date": datetime.date(2001, 4, 15),
            }, {
                "start_date": datetime.date(2001, 4, 16),
                "due_date": datetime.date(2001, 6, 15),
                "end_date": datetime.date(2001, 6, 15),
            }]
        }
        serializer = InterventionReportingRequirementCreateSerializer(
            data=data,
            context=self.context
        )
        self.assertTrue(serializer.is_valid())
        serializer.create(serializer.validated_data)

        requirement_qs_count = ReportingRequirement.objects.filter(
            intervention=self.intervention,
            report_type=report_type,
        ).count()
        self.assertEqual(requirement_qs_count, 2)
 def test_update_create_qpr(self):
     """Updating existing qpr reporting requirements and create new"""
     report_type = ReportingRequirement.TYPE_QPR
     requirement_qs = ReportingRequirement.objects.filter(
         intervention=self.intervention,
         report_type=report_type,
     )
     data = {
         "report_type": report_type,
         "reporting_requirements": [{
             "start_date": datetime.date(2001, 1, 1),
             "end_date": datetime.date(2001, 3, 31),
             "due_date": datetime.date(2001, 4, 15),
         }, {
             "start_date": datetime.date(2001, 4, 1),
             "end_date": datetime.date(2001, 5, 30),
             "due_date": datetime.date(2001, 5, 15),
         }]
     }
     serializer = InterventionReportingRequirementCreateSerializer(
         data=data,
         context=self.context
     )
     self.assertTrue(serializer.is_valid())
     serializer.create(serializer.validated_data)
     self.assertEqual(requirement_qs.count(), 2)
    def test_create_hr(self):
        """Creating new hr reporting requirements

        When none currently existing
        """
        AppliedIndicatorFactory(
            is_high_frequency=True,
            lower_result=self.lower_result
        )
        requirement_qs = ReportingRequirement.objects.filter(
            intervention=self.intervention,
            report_type=ReportingRequirement.TYPE_HR,
        )
        data = {
            "report_type": ReportingRequirement.TYPE_HR,
            "reporting_requirements": [
                {"start_date": datetime.date(2001, 3, 15),
                 "due_date": datetime.date(2001, 4, 15),
                 "end_date": datetime.date(2001, 4, 15)},
                {"start_date": datetime.date(2001, 4, 16),
                 "due_date": datetime.date(2001, 5, 15),
                 "end_date": datetime.date(2001, 5, 15)}
            ]
        }
        serializer = InterventionReportingRequirementCreateSerializer(
            data=data,
            context=self.context
        )
        self.assertTrue(serializer.is_valid())
        serializer.create(serializer.validated_data)
        self.assertEqual(requirement_qs.count(), 2)