def test_status_with_informatieobject_indicatie_gebruiksrecht_null(self): zaak = ZaakFactory.create(zaaktype=self.zaaktype) zaak_url = reverse(zaak) io = EnkelvoudigInformatieObjectFactory.create(indicatie_gebruiksrecht=None) ZaakInformatieObjectFactory.create(zaak=zaak, informatieobject=io.canonical) resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P10Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze=BrondatumArchiefprocedureAfleidingswijze.afgehandeld, zaaktype=self.zaaktype, ) ResultaatFactory.create(zaak=zaak, resultaattype=resultaattype) list_url = reverse("status-list") response = self.client.post( list_url, { "zaak": zaak_url, "statustype": f"http://testserver{self.statustype_end_url}", "datumStatusGezet": isodatetime(2019, 7, 22, 13, 00, 00), }, ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) validation_error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(validation_error["code"], "indicatiegebruiksrecht-unset")
def test_status_with_informatieobject_lock(self): self.create_zaak_besluit_services() zaak = self.create_zaak(zaaktype=self.zaaktype) zaak_url = reverse(zaak) io = EnkelvoudigInformatieObjectFactory.create() io_url = io.get_url() ZaakInformatieObjectFactory.create(zaak=zaak, informatieobject=io_url) io.canonical.lock_document(io.uuid) self.adapter.get(io_url, json=serialise_eio(io, io_url, locked=True)) resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P10Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze= BrondatumArchiefprocedureAfleidingswijze.afgehandeld, zaaktype=self.zaaktype, ) ResultaatFactory.create(zaak=zaak, resultaattype=resultaattype) list_url = reverse("status-list") response = self.client.post( list_url, { "zaak": zaak_url, "statustype": f"http://testserver{self.statustype_end_url}", "datumStatusGezet": isodatetime(2019, 7, 22, 13, 00, 00), }, ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) validation_error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(validation_error["code"], "informatieobject-locked")
def test_eindstatus_with_informatieobject_lock(self, m): REMOTE_DOCUMENT = "https://external.nl/documenten/123" m.get( REMOTE_DOCUMENT, json=get_eio_response(REMOTE_DOCUMENT, locked=True), ) zaak = ZaakFactory.create(zaaktype=self.zaaktype) zaak_url = reverse(zaak) ZaakInformatieObjectFactory.create(zaak=zaak, informatieobject=REMOTE_DOCUMENT) resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P10Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze=BrondatumArchiefprocedureAfleidingswijze.afgehandeld, zaaktype=self.zaaktype, ) ResultaatFactory.create(zaak=zaak, resultaattype=resultaattype) list_url = reverse("status-list") response = self.client.post( list_url, { "zaak": zaak_url, "statustype": f"http://testserver{self.statustype_end_url}", "datumStatusGezet": isodatetime(2019, 7, 22, 13, 00, 00), }, ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) validation_error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(validation_error["code"], "informatieobject-locked")
def test_add_resultaat_on_zaak_with_remote_zaakobjecten_causes_archiefactiedatum_to_be_set( self, ): """ Add RESULTAAT that causes `archiefactiedatum` to be set. """ zaak = ZaakFactory.create() zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid) zaak_object1 = ZaakObjectFactory.create(zaak=zaak) zaak_object2 = ZaakObjectFactory.create( zaak=zaak, object_type=zaak_object1.object_type) resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P10Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze= BrondatumArchiefprocedureAfleidingswijze.zaakobject, brondatum_archiefprocedure_datumkenmerk="einddatum", brondatum_archiefprocedure_objecttype=zaak_object1.object_type, zaaktype=zaak.zaaktype, ) resultaattype_url = reverse(resultaattype) responses = { zaak_object1.object: { "einddatum": isodatetime(2019, 1, 1) }, zaak_object2.object: { "einddatum": isodatetime(2022, 1, 1) }, } # add resultaat resultaat_create_url = get_operation_url("resultaat_create") data = { "zaak": zaak_url, "resultaattype": f"http://testserver{resultaattype_url}", "toelichting": "", } response = self.client.post(resultaat_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) # add final status to the case to close it and to calculate archive parameters status_create_url = get_operation_url("status_create") statustype = StatusTypeFactory.create(zaaktype=zaak.zaaktype) statustype_url = reverse(statustype) data = { "zaak": zaak_url, "statustype": f"http://testserver{statustype_url}", "datumStatusGezet": "2018-10-18T20:00:00Z", } with mock_client(responses): response = self.client.post(status_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) zaak.refresh_from_db() self.assertEqual(zaak.archiefactiedatum, date(2032, 1, 1))
def test_add_resultaat_on_zaak_with_external_gerelateerde_zaak_(self): """ Add RESULTAAT that causes `archiefactiedatum` to be set. """ zaak = ZaakFactory.create() zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid) zaaktype_url = f"http://testserver.com{reverse(zaak.zaaktype)}" zaak2 = "https://external.nl/zaken/123" zaak2_data = get_zaak_response(zaak2, zaaktype_url) zaak2_data["einddatum"] = "2022-01-01" zaak3 = "https://external.nl/zaken/456" zaak3_data = get_zaak_response(zaak3, zaaktype_url) zaak3_data["einddatum"] = "2025-01-01" RelevanteZaakRelatieFactory.create(zaak=zaak, url=zaak2) RelevanteZaakRelatieFactory.create(zaak=zaak, url=zaak3) resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P5Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze= BrondatumArchiefprocedureAfleidingswijze.gerelateerde_zaak, brondatum_archiefprocedure_procestermijn=None, zaaktype=zaak.zaaktype, ) resultaattype_url = reverse(resultaattype) resultaat_create_url = get_operation_url("resultaat_create") data = { "zaak": f"http://testserver.com{zaak_url}", "resultaattype": f"http://testserver.com{resultaattype_url}", "toelichting": "", } response = self.client.post(resultaat_create_url, data, HTTP_HOST="testserver.com") self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) # add final status to the case to close it and to calculate archive parameters status_create_url = get_operation_url("status_create") statustype = StatusTypeFactory.create(zaaktype=zaak.zaaktype) statustype_url = reverse(statustype) data = { "zaak": f"http://testserver.com{zaak_url}", "statustype": f"http://testserver.com{statustype_url}", "datumStatusGezet": "2018-10-18T20:00:00Z", } with requests_mock.Mocker(real_http=True) as m: m.register_uri("GET", zaak2, json=zaak2_data) m.register_uri("GET", zaak3, json=zaak3_data) response = self.client.post(status_create_url, data, HTTP_HOST="testserver.com") self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data)
def test_add_resultaat_on_zaak_with_afleidingswijze_gerelateerde_zaak_causes_archiefactiedatum_to_be_set( self, ): """ Add RESULTAAT that causes `archiefactiedatum` to be set. """ zaak = ZaakFactory.create() zaak2 = ZaakFactory.create(einddatum="2022-01-01") zaak3 = ZaakFactory.create(einddatum="2025-01-01") RelevanteZaakRelatieFactory.create(zaak=zaak, url=zaak2) RelevanteZaakRelatieFactory.create(zaak=zaak, url=zaak3) zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid) resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P5Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze= BrondatumArchiefprocedureAfleidingswijze.gerelateerde_zaak, brondatum_archiefprocedure_procestermijn=None, zaaktype=zaak.zaaktype, ) resultaattype_url = reverse(resultaattype) resultaat_create_url = get_operation_url("resultaat_create") data = { "zaak": f"http://testserver.com{zaak_url}", "resultaattype": f"http://testserver.com{resultaattype_url}", "toelichting": "", } response = self.client.post(resultaat_create_url, data, HTTP_HOST="testserver.com") self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) # add final status to the case to close it and to calculate archive parameters status_create_url = get_operation_url("status_create") statustype = StatusTypeFactory.create(zaaktype=zaak.zaaktype) statustype_url = reverse(statustype) data = { "zaak": f"http://testserver.com{zaak_url}", "statustype": f"http://testserver.com{statustype_url}", "datumStatusGezet": "2018-10-18T20:00:00Z", } response = self.client.post(status_create_url, data, HTTP_HOST="testserver.com") self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) zaak.refresh_from_db() self.assertEqual(zaak.archiefactiedatum, date(2030, 1, 1))
def zet_statussen_resultaat(self): statustype = StatusTypeFactory.create( zaaktype=self.references["zaaktype"]) statustype_url = reverse(statustype) statustype_overlast_geconstateerd = StatusTypeFactory.create( zaaktype=self.references["zaaktype"]) statustype_overlast_geconstateerd_url = reverse( statustype_overlast_geconstateerd) resultaattype = ResultaatTypeFactory.create( zaaktype=self.references["zaaktype"], archiefactietermijn="P10Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze= BrondatumArchiefprocedureAfleidingswijze.afgehandeld, ) resultaattype_url = reverse(resultaattype) status_create_url = get_operation_url("status_create") resultaat_create_url = get_operation_url("resultaat_create") created = parser.parse(self.data["datetime"]) self.client.post( status_create_url, { "zaak": self.references["zaak_url"], "statustype": f"http://testserver{statustype_url}", "datumStatusGezet": created.isoformat(), }, ) self.client.post( resultaat_create_url, { "zaak": self.references["zaak_url"], "resultaattype": f"http://testserver{resultaattype_url}", "toelichting": "", }, ) self.client.post( status_create_url, { "zaak": self.references["zaak_url"], "statustype": f"http://testserver{statustype_overlast_geconstateerd_url}", "datumStatusGezet": parser.parse(self.data["datetime_overlast"]).isoformat(), }, ) self.references["statustype"] = statustype self.references[ "statustype_overlast_geconstateerd"] = statustype_overlast_geconstateerd
def test_not_allowed_to_change_resultaattype(self): resultaat = ResultaatFactory.create() url = reverse(resultaat) resultaattype = ResultaatTypeFactory.create() resultaattype_url = reverse(resultaattype) response = self.client.patch( url, {"resultaattype": f"http://testserver{resultaattype_url}"}) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) validation_error = get_validation_errors(response, "resultaattype") self.assertEqual(validation_error["code"], IsImmutableValidator.code)
def test_add_resultaat_on_zaak_with_eigenschap_causes_archiefactiedatum_to_be_set( self, ): """ Add RESULTAAT that causes `archiefactiedatum` to be set. """ zaak = ZaakFactory.create() zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid) ZaakEigenschapFactory.create(zaak=zaak, _naam="brondatum", waarde=isodatetime(2019, 1, 1)) resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P10Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze= BrondatumArchiefprocedureAfleidingswijze.eigenschap, brondatum_archiefprocedure_datumkenmerk="brondatum", zaaktype=zaak.zaaktype, ) resultaattype_url = reverse(resultaattype) resultaat_create_url = get_operation_url("resultaat_create") data = { "zaak": zaak_url, "resultaattype": f"http://testserver{resultaattype_url}", "toelichting": "", } self.assertIsNone(zaak.archiefactiedatum) response = self.client.post(resultaat_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) # add final status to the case to close it and to calculate archive parameters statustype = StatusTypeFactory.create(zaaktype=zaak.zaaktype) statustype_url = reverse(statustype) status_create_url = get_operation_url("status_create") data = { "zaak": zaak_url, "statustype": f"http://testserver{statustype_url}", "datumStatusGezet": "2018-10-18T20:00:00Z", } response = self.client.post(status_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) zaak.refresh_from_db() self.assertEqual(zaak.archiefactiedatum, date(2029, 1, 1))
def test_add_resultaat_on_zaak_with_ander_datumkenmerk_causes_archiefactiedatum_to_remain_empty( self, ): """ Add RESULTAAT that causes `archiefactiedatum` to remain empty. It needs to be manually set based on the information in the RESULTAATTYPE. """ zaak = ZaakFactory.create() zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid) resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P10Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze= BrondatumArchiefprocedureAfleidingswijze.ander_datumkenmerk, brondatum_archiefprocedure_datumkenmerk="einddatum", brondatum_archiefprocedure_registratie= "LichtgevendeObjectenRegistratie", brondatum_archiefprocedure_objecttype="Lantaarnpaal", zaaktype=zaak.zaaktype, ) resultaattype_url = reverse(resultaattype) # add resultaat resultaat_create_url = get_operation_url("resultaat_create") data = { "zaak": zaak_url, "resultaattype": f"http://testserver{resultaattype_url}", "toelichting": "", } response = self.client.post(resultaat_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) # add final status to the case to close it and to calculate archive parameters status_create_url = get_operation_url("status_create") statustype = StatusTypeFactory.create(zaaktype=zaak.zaaktype) statustype_url = reverse(statustype) data = { "zaak": zaak_url, "statustype": f"http://testserver{statustype_url}", "datumStatusGezet": "2018-10-18T20:00:00Z", } response = self.client.post(status_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) zaak.refresh_from_db() self.assertIsNone(zaak.archiefactiedatum)
def test_add_resultaat_on_zaak_with_afleidingswijze_gerelateerde_zaak_without_relevante_zaken_gives_400( self, ): """ Add RESULTAAT that causes `archiefactiedatum` to be set. """ zaak = ZaakFactory.create() zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid) resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P5Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze= BrondatumArchiefprocedureAfleidingswijze.gerelateerde_zaak, brondatum_archiefprocedure_procestermijn=None, zaaktype=zaak.zaaktype, ) resultaattype_url = reverse(resultaattype) resultaat_create_url = get_operation_url("resultaat_create") data = { "zaak": zaak_url, "resultaattype": f"http://testserver{resultaattype_url}", "toelichting": "", } response = self.client.post(resultaat_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) # add final status to the case to close it and to calculate archive parameters status_create_url = get_operation_url("status_create") statustype = StatusTypeFactory.create(zaaktype=zaak.zaaktype) statustype_url = reverse(statustype) data = { "zaak": zaak_url, "statustype": f"http://testserver{statustype_url}", "datumStatusGezet": "2018-10-18T20:00:00Z", } response = self.client.post(status_create_url, data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.data) error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(error["code"], "archiefactiedatum-error") zaak.refresh_from_db() self.assertEqual(zaak.archiefactiedatum, None)
def test_add_resultaat_on_zaak_with_hoofdzaak_causes_archiefactiedatum_to_be_set( self): """ Add RESULTAAT that causes `archiefactiedatum` to be set. """ hoofd_zaak = ZaakFactory.create(einddatum=date(2019, 1, 1)) zaak = ZaakFactory.create(hoofdzaak=hoofd_zaak) zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid) resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P10Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze= BrondatumArchiefprocedureAfleidingswijze.hoofdzaak, zaaktype=zaak.zaaktype, ) resultaattype_url = reverse(resultaattype) # add resultaat resultaat_create_url = get_operation_url("resultaat_create") data = { "zaak": zaak_url, "resultaattype": resultaattype_url, "toelichting": "" } response = self.client.post(resultaat_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) # add final status to the case to close it and to calculate archive parameters statustype = StatusTypeFactory.create(zaaktype=zaak.zaaktype) statustype_url = reverse(statustype) status_create_url = get_operation_url("status_create") data = { "zaak": zaak_url, "statustype": statustype_url, "datumStatusGezet": "2018-10-18T20:00:00Z", } response = self.client.post(status_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) zaak.refresh_from_db() self.assertEqual(zaak.archiefactiedatum, date(2029, 1, 1))
def test_add_resultaat_on_zaak_causes_archiefnominatie_to_be_copied(self): """ Add RESULTAAT that causes `archiefnominatie` to be copied from RESULTAATTYPE. """ zaak = ZaakFactory.create() zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid) # add a result for the case resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P10Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze= BrondatumArchiefprocedureAfleidingswijze.afgehandeld, zaaktype=zaak.zaaktype, ) resultaattype_url = reverse(resultaattype) resultaat_create_url = get_operation_url("resultaat_create") data = { "zaak": zaak_url, "resultaattype": f"http://testserver{resultaattype_url}", "toelichting": "", } self.assertIsNone(zaak.archiefnominatie) response = self.client.post(resultaat_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) # add final status to the case to close it and to calculate archive parameters statustype = StatusTypeFactory.create(zaaktype=zaak.zaaktype) statustype_url = reverse(statustype) status_create_url = get_operation_url("status_create") data = { "zaak": zaak_url, "statustype": f"http://testserver{statustype_url}", "datumStatusGezet": "2018-10-18T20:00:00Z", } response = self.client.post(status_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) zaak.refresh_from_db() self.assertEqual(zaak.archiefnominatie, Archiefnominatie.blijvend_bewaren)
def test_resultaattype_incorrect_zaaktype(self): zaak = ZaakFactory.create() zaak_url = reverse("zaak-detail", kwargs={"uuid": zaak.uuid}) resultaattype = ResultaatTypeFactory.create() resultaattype_url = reverse(resultaattype) list_url = reverse("resultaat-list") response = self.client.post(list_url, { "zaak": zaak_url, "resultaattype": resultaattype_url }) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) validation_error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(validation_error["code"], "zaaktype-mismatch")
def test_create_resultaat(self): zaak = ZaakFactory.create() zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid) resultaattype = ResultaatTypeFactory.create() add_url = reverse("admin:zaken_resultaat_add") data = { "uuid": uuid.uuid4(), "zaak": zaak.id, "_resultaattype": resultaattype.id, "toelichting": "desc", } self.client.post(add_url, data) self.assertEqual(Resultaat.objects.count(), 1) resultaat = Resultaat.objects.get() resultaat_url = get_operation_url("resultaat_read", uuid=resultaat.uuid, zaak_uuid=zaak.uuid) self.assertEqual(AuditTrail.objects.count(), 1) audittrail = AuditTrail.objects.get() self.assertEqual(audittrail.bron, "ZRC") self.assertEqual(audittrail.actie, "create") self.assertEqual(audittrail.resultaat, 0) self.assertEqual(audittrail.applicatie_weergave, "admin") self.assertEqual(audittrail.gebruikers_id, f"{self.user.id}"), self.assertEqual(audittrail.gebruikers_weergave, self.user.get_full_name()), self.assertEqual(audittrail.hoofd_object, f"http://testserver{zaak_url}"), self.assertEqual(audittrail.resource, "resultaat"), self.assertEqual(audittrail.resource_url, f"http://testserver{resultaat_url}"), self.assertEqual(audittrail.resource_weergave, resultaat.unique_representation()), self.assertEqual(audittrail.oud, None) new_data = audittrail.nieuw self.assertEqual(new_data["toelichting"], "desc")
def test_resultaat_create_fail_send_notification_create_db_entry(self): zaak = ZaakFactory.create() zaak_url = reverse(zaak) resultaattype = ResultaatTypeFactory.create(zaaktype=zaak.zaaktype) resultaattype_url = reverse(resultaattype) url = get_operation_url("resultaat_create") data = { "zaak": f"http://testserver{zaak_url}", "resultaattype": f"http://testserver{resultaattype_url}", } with capture_on_commit_callbacks(execute=True): response = self.client.post(url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) data = response.json() self.assertEqual(StatusLog.objects.count(), 1) logged_warning = StatusLog.objects.get() failed = FailedNotification.objects.get() message = { "aanmaakdatum": "2019-01-01T12:00:00Z", "actie": "create", "hoofdObject": f"http://testserver{zaak_url}", "kanaal": "zaken", "kenmerken": { "bronorganisatie": zaak.bronorganisatie, "zaaktype": f"http://testserver{reverse(zaak.zaaktype)}", "vertrouwelijkheidaanduiding": zaak.vertrouwelijkheidaanduiding, }, "resource": "resultaat", "resourceUrl": data["url"], } self.assertEqual(failed.statuslog_ptr, logged_warning) self.assertEqual(failed.message, message)
def test_add_resultaat_on_zaak_with_incorrect_eigenschap_fails(self): """ Attempt to add RESULTAAT with incorrect ZTC-configuration. """ zaak = ZaakFactory.create() zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid) resultaattype = ResultaatTypeFactory.create( archiefactietermijn="P10Y", archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze= BrondatumArchiefprocedureAfleidingswijze.eigenschap, brondatum_archiefprocedure_datumkenmerk="brondatum", zaaktype=zaak.zaaktype, ) resultaattype_url = reverse(resultaattype) # add resultaat resultaat_create_url = get_operation_url("resultaat_create") data = { "zaak": zaak_url, "resultaattype": f"http://testserver{resultaattype_url}", "toelichting": "", } response = self.client.post(resultaat_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) # add final status to the case to close it and to calculate archive parameters statustype = StatusTypeFactory.create(zaaktype=zaak.zaaktype) statustype_url = reverse(statustype) status_create_url = get_operation_url("status_create") data = { "zaak": zaak_url, "statustype": statustype_url, "datumStatusGezet": "2018-10-18T20:00:00Z", } response = self.client.post(status_create_url, data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_create_and_delete_resultaat_audittrails(self): zaak_response = self._create_zaak() zaak = Zaak.objects.get() resultaattype = ResultaatTypeFactory.create(zaaktype=zaak.zaaktype) resultaattype_url = reverse(resultaattype) url = reverse(Resultaat) resultaat_data = { "zaak": zaak_response["url"], "resultaattype": resultaattype_url, } response = self.client.post(url, resultaat_data, **ZAAK_WRITE_KWARGS) resultaat_response = response.data audittrails = AuditTrail.objects.filter( hoofd_object=zaak_response["url"]).order_by("pk") self.assertEqual(audittrails.count(), 2) # Verify that the audittrail for the Resultaat creation contains the # correct information resultaat_create_audittrail = audittrails[1] self.assertEqual(resultaat_create_audittrail.bron, "ZRC") self.assertEqual(resultaat_create_audittrail.actie, "create") self.assertEqual(resultaat_create_audittrail.resultaat, 201) self.assertEqual(resultaat_create_audittrail.oud, None) self.assertEqual(resultaat_create_audittrail.nieuw, resultaat_response) response = self.client.delete(resultaat_response["url"], **ZAAK_WRITE_KWARGS) self.assertEqual(audittrails.count(), 3) # Verify that the audittrail for the Resultaat deletion contains the # correct information resultaat_delete_audittrail = audittrails[2] self.assertEqual(resultaat_delete_audittrail.bron, "ZRC") self.assertEqual(resultaat_delete_audittrail.actie, "destroy") self.assertEqual(resultaat_delete_audittrail.resultaat, 204) self.assertEqual(resultaat_delete_audittrail.oud, resultaat_response) self.assertEqual(resultaat_delete_audittrail.nieuw, None)
def test_zaak_archiefactiedatum_afleidingswijze_ingangsdatum_besluit(self): zaaktype = ZaakTypeFactory.create() zaak = ZaakFactory.create(zaaktype=zaaktype) zaak_url = reverse(zaak) statustype1 = StatusTypeFactory.create(zaaktype=zaaktype) statustype1_url = reverse(statustype1) statustype2 = StatusTypeFactory.create(zaaktype=zaaktype) statustype2_url = reverse(statustype2) resultaattype = ResultaatTypeFactory.create( zaaktype=zaaktype, archiefactietermijn=relativedelta(years=10), archiefnominatie=Archiefnominatie.blijvend_bewaren, brondatum_archiefprocedure_afleidingswijze=BrondatumArchiefprocedureAfleidingswijze.ingangsdatum_besluit, ) resultaattype_url = reverse(resultaattype) BesluitFactory.create(zaak=zaak, ingangsdatum="2020-05-03") # Set initial status status_list_url = reverse("status-list") response = self.client.post( status_list_url, { "zaak": zaak_url, "statustype": f"http://testserver{statustype1_url}", "datumStatusGezet": isodatetime(2018, 10, 1, 10, 00, 00), }, ) self.assertEqual( response.status_code, status.HTTP_201_CREATED, response.content ) zaak.refresh_from_db() self.assertIsNone(zaak.einddatum) # add a result for the case resultaat_create_url = get_operation_url("resultaat_create") data = { "zaak": zaak_url, "resultaattype": f"http://testserver{resultaattype_url}", "toelichting": "", } response = self.client.post(resultaat_create_url, data) self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.data) # Set eindstatus datum_status_gezet = utcdatetime(2018, 10, 22, 10, 00, 00) response = self.client.post( status_list_url, { "zaak": zaak_url, "statustype": f"http://testserver{statustype2_url}", "datumStatusGezet": datum_status_gezet.isoformat(), }, ) self.assertEqual( response.status_code, status.HTTP_201_CREATED, response.content ) zaak.refresh_from_db() self.assertEqual(zaak.einddatum, datum_status_gezet.date()) self.assertEqual( zaak.archiefactiedatum, date(2030, 5, 3) # 2020-05-03 + 10 years )