Ejemplo n.º 1
0
 def test_delete(self):
     date = datetime.date.today() + datetime.timedelta(days=10)
     requirement = SpecialReportingRequirementFactory(
         intervention=self.intervention,
         due_date=date,
         description="Old",
     )
     response = self.forced_auth_req(
         "delete",
         self._get_url(requirement),
         user=self.unicef_staff,
     )
     self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
     self.assertFalse(
         SpecialReportingRequirement.objects.filter(
             pk=requirement.pk).exists())
Ejemplo n.º 2
0
 def test_get(self):
     requirement = SpecialReportingRequirementFactory(
         intervention=self.intervention,
         due_date=datetime.date(2001, 4, 15),
         description="Current",
     )
     response = self.forced_auth_req(
         "get",
         self._get_url(requirement),
         user=self.unicef_staff,
     )
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.data["id"], requirement.pk)
     self.assertEqual(response.data["intervention"], self.intervention.pk)
     self.assertEqual(response.data["due_date"], str(requirement.due_date))
     self.assertEqual(response.data["description"], "Current")
Ejemplo n.º 3
0
 def test_delete_invalid_old(self):
     """Cannot delete special reporting requirements in the past"""
     requirement = SpecialReportingRequirementFactory(
         intervention=self.intervention,
         due_date=datetime.date(2001, 4, 15),
         description="Old",
     )
     response = self.forced_auth_req(
         "delete",
         self._get_url(requirement),
         user=self.unicef_staff,
     )
     self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
     self.assertEqual(
         response.data,
         ["Cannot delete special reporting requirements in the past."])
     self.assertTrue(
         SpecialReportingRequirement.objects.filter(
             pk=requirement.pk).exists())
Ejemplo n.º 4
0
 def test_patch(self):
     requirement = SpecialReportingRequirementFactory(
         intervention=self.intervention,
         due_date=datetime.date(2001, 4, 15),
         description="Old",
     )
     response = self.forced_auth_req("patch",
                                     self._get_url(requirement),
                                     user=self.unicef_staff,
                                     data={
                                         "due_date":
                                         datetime.date(2001, 4, 15),
                                         "description": "New"
                                     })
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.data["description"], "New")
     requirement_update = SpecialReportingRequirement.objects.get(
         pk=requirement.pk)
     self.assertEqual(requirement_update.description, "New")