Esempio n. 1
0
    def test_eindstatus_with_informatieobject_unlocked(self, m):
        REMOTE_DOCUMENT = "https://external.nl/documenten/123"
        m.get(
            REMOTE_DOCUMENT,
            json=get_eio_response(
                REMOTE_DOCUMENT, locked=False, indicatieGebruiksrecht=False,
            ),
        )
        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_201_CREATED)
Esempio n. 2
0
    def test_status_with_informatieobject_indicatie_gebruiksrecht_null(self, m):
        REMOTE_DOCUMENT = "https://external.nl/documenten/123"
        m.get(
            REMOTE_DOCUMENT,
            json=get_eio_response(REMOTE_DOCUMENT, indicatieGebruiksrecht=None),
        )
        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"], "indicatiegebruiksrecht-unset")
Esempio n. 3
0
    def test_destroy_with_external_informatieobject(self):
        oio = f"{self.base}objectinformatieobjecten/{uuid.uuid4()}"
        informatieobjecttype = InformatieObjectTypeFactory.create()

        with requests_mock.Mocker(real_http=True) as m:
            mock_service_oas_get(m, APITypes.drc, self.base)
            m.get(
                self.document,
                json=get_eio_response(
                    self.document,
                    informatieobjecttype=f"http://openzaak.nl{reverse(informatieobjecttype)}",
                ),
            )
            m.delete(oio, status_code=204)

            bio = BesluitInformatieObjectFactory.create(
                informatieobject=self.document, _objectinformatieobject_url=oio
            )
            bio_url = reverse(bio)

            response = self.client.delete(bio_url, HTTP_HOST="openzaak.nl")

        self.assertEqual(
            response.status_code, status.HTTP_204_NO_CONTENT, response.data
        )
        self.assertEqual(BesluitInformatieObject.objects.count(), 0)

        history_delete = [
            req
            for req in m.request_history
            if req.method == "DELETE" and req.url == oio
        ]
        self.assertEqual(len(history_delete), 1)
Esempio n. 4
0
    def test_destroy_with_external_informatieobject_fail_send(self):
        oio = f"{self.base}objectinformatieobjecten/{uuid.uuid4()}"
        informatieobjecttype = InformatieObjectTypeFactory.create()

        with requests_mock.Mocker(real_http=True) as m:
            mock_service_oas_get(m, APITypes.drc, self.base)
            m.get(
                self.document,
                json=get_eio_response(
                    self.document,
                    informatieobjecttype=f"http://openzaak.nl{reverse(informatieobjecttype)}",
                ),
            )
            m.delete(oio, status_code=404, text="Not found")

            bio = BesluitInformatieObjectFactory.create(
                informatieobject=self.document, _objectinformatieobject_url=oio
            )
            bio_url = reverse(bio)

            response = self.client.delete(bio_url, HTTP_HOST="openzaak.nl")

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        error = get_validation_errors(response, "informatieobject")
        self.assertEqual(error["code"], "pending-relations")
Esempio n. 5
0
    def test_besluittype_external_iotype_external_success(self):
        catalogus = f"{self.base}catalogussen/1c8e36be-338c-4c07-ac5e-1adf55bec04a"
        besluittype = f"{self.base}besluittypen/b71f72ef-198d-44d8-af64-ae1932df830a"
        besluit = BesluitFactory.create(besluittype=besluittype)
        besluit_url = f"http://openbesluit.nl{reverse(besluit)}"
        informatieobjecttype = f"{self.base}informatieobjecttypen/{uuid.uuid4()}"
        besluittype_data = get_besluittype_response(catalogus, besluittype)
        besluittype_data["informatieobjecttypen"] = [informatieobjecttype]

        with requests_mock.Mocker(real_http=True) as m:
            mock_service_oas_get(m, APITypes.drc, self.base)
            m.get(besluittype, json=besluittype_data)
            m.get(
                informatieobjecttype,
                json=get_informatieobjecttype_response(catalogus, informatieobjecttype),
            )
            m.get(
                self.document,
                json=get_eio_response(
                    self.document, informatieobjecttype=informatieobjecttype
                ),
            )
            m.post(
                f"{self.base}objectinformatieobjecten",
                json=get_oio_response(self.document, besluit_url),
                status_code=201,
            )

            response = self.client.post(
                self.list_url,
                {"besluit": besluit_url, "informatieobject": self.document},
                HTTP_HOST="openbesluit.nl",
            )

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Esempio n. 6
0
    def test_besluittype_external_iotype_internal(self):
        catalogus = f"{self.base}catalogussen/1c8e36be-338c-4c07-ac5e-1adf55bec04a"
        besluittype = f"{self.base}besluittypen/b71f72ef-198d-44d8-af64-ae1932df830a"
        besluit = BesluitFactory.create(besluittype=besluittype)
        besluit_url = f"http://openbesluit.nl{reverse(besluit)}"
        informatieobjecttype = InformatieObjectTypeFactory.create()
        eio_response = get_eio_response(
            self.document,
            informatieobjecttype=f"http://openbesluit.nl{reverse(informatieobjecttype)}",
        )

        with requests_mock.Mocker(real_http=True) as m:
            m.get(besluittype, json=get_besluittype_response(catalogus, besluittype))
            m.get(self.document, json=eio_response)

            response = self.client.post(
                self.list_url,
                {"besluit": besluit_url, "informatieobject": self.document},
                HTTP_HOST="openbesluit.nl",
            )

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(
            error["code"], "missing-besluittype-informatieobjecttype-relation"
        )
Esempio n. 7
0
    def test_besluittype_internal_iotype_internal_fail(self):
        besluit = BesluitFactory.create()
        besluit_url = f"http://openbesluit.nl{reverse(besluit)}"
        informatieobjecttype = InformatieObjectTypeFactory.create()
        eio_response = get_eio_response(
            self.document,
            informatieobjecttype=
            f"http://openbesluit.nl{reverse(informatieobjecttype)}",
        )

        with requests_mock.Mocker(real_http=True) as m:
            m.get(self.document, json=eio_response)
            response = self.client.post(
                self.list_url,
                {
                    "besluit": besluit_url,
                    "informatieobject": self.document
                },
                HTTP_HOST="openbesluit.nl",
            )

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"],
                         "missing-besluittype-informatieobjecttype-relation")
    def test_zaaktype_internal_iotype_external(self):
        zaak = ZaakFactory.create()
        zaak_url = f"http://openzaak.nl{reverse(zaak)}"
        informatieobjecttype = f"{self.base}informatieobjecttypen/{uuid.uuid4()}"
        catalogus = f"{self.base}catalogussen/1c8e36be-338c-4c07-ac5e-1adf55bec04a"

        with requests_mock.Mocker(real_http=True) as m:
            m.get(
                informatieobjecttype,
                json=get_informatieobjecttype_response(catalogus, informatieobjecttype),
            )
            m.get(
                catalogus, json=get_catalogus_response(catalogus, informatieobjecttype)
            )
            m.get(
                self.document,
                json=get_eio_response(
                    self.document, informatieobjecttype=informatieobjecttype
                ),
            )

            response = self.client.post(
                self.list_url,
                {"zaak": zaak_url, "informatieobject": self.document},
                HTTP_HOST="openzaak.nl",
            )

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(
            error["code"], "missing-zaaktype-informatieobjecttype-relation"
        )
    def test_zaaktype_external_iotype_external_success(self):
        catalogus = f"{self.base}catalogussen/1c8e36be-338c-4c07-ac5e-1adf55bec04a"
        zaaktype = f"{self.base}zaaktypen/b71f72ef-198d-44d8-af64-ae1932df830a"
        zaak = ZaakFactory.create(zaaktype=zaaktype)
        zaak_url = f"http://openzaak.nl{reverse(zaak)}"
        informatieobjecttype = f"{self.base}informatieobjecttypen/{uuid.uuid4()}"
        zaaktype_data = get_zaaktype_response(catalogus, zaaktype)
        zaaktype_data["informatieobjecttypen"] = [informatieobjecttype]

        with requests_mock.Mocker(real_http=True) as m:
            m.get(zaaktype, json=zaaktype_data)
            m.get(
                informatieobjecttype,
                json=get_informatieobjecttype_response(catalogus, informatieobjecttype),
            )
            m.get(
                self.document,
                json=get_eio_response(
                    self.document, informatieobjecttype=informatieobjecttype
                ),
            )
            m.post(
                f"{self.base}objectinformatieobjecten",
                json=get_oio_response(self.document, zaak_url),
                status_code=201,
            )

            response = self.client.post(
                self.list_url,
                {"zaak": zaak_url, "informatieobject": self.document},
                HTTP_HOST="openzaak.nl",
            )

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Esempio n. 10
0
    def test_cannot_set_archiefstatus_when_not_all_documents_are_gearchiveerd(self, m):
        REMOTE_DOCUMENT = "https://external.nl/documenten/123"

        m.get(
            REMOTE_DOCUMENT,
            json=get_eio_response(REMOTE_DOCUMENT, status=Statussen.ter_vaststelling),
        )

        zaak = ZaakFactory.create(
            archiefnominatie=Archiefnominatie.vernietigen,
            archiefactiedatum=date.today(),
        )
        ZaakInformatieObjectFactory.create(zaak=zaak, informatieobject=REMOTE_DOCUMENT)
        zaak_patch_url = get_operation_url("zaak_partial_update", uuid=zaak.uuid)
        data = {"archiefstatus": Archiefstatus.gearchiveerd}

        response = self.client.patch(zaak_patch_url, data, **ZAAK_WRITE_KWARGS)

        self.assertEqual(
            response.status_code, status.HTTP_400_BAD_REQUEST, response.data
        )
    def test_filter_by_external_informatieobject(self):
        base = "https://external.documenten.nl/api/v1/"
        document = f"{base}enkelvoudiginformatieobjecten/{uuid.uuid4()}"
        zio_type = ZaakTypeInformatieObjectTypeFactory.create(
            informatieobjecttype__concept=False, zaaktype__concept=False
        )
        zaak = ZaakFactory.create(zaaktype=zio_type.zaaktype)
        zaak_url = f"http://openzaak.nl{reverse(zaak)}"
        eio_response = get_eio_response(
            document,
            informatieobjecttype=f"http://openzaak.nl{reverse(zio_type.informatieobjecttype)}",
        )

        with requests_mock.Mocker() as m:
            m.get(document, json=eio_response)
            m.post(
                "https://external.documenten.nl/api/v1/objectinformatieobjecten",
                json=get_oio_response(document, zaak_url),
                status_code=201,
            )

            response = self.client.post(
                reverse(ZaakInformatieObject),
                {"zaak": zaak_url, "informatieobject": document},
                HTTP_HOST="openzaak.nl",
            )

        io_url = response.data["informatieobject"]
        zio_list_url = reverse("zaakinformatieobject-list")

        response = self.client.get(
            zio_list_url, {"informatieobject": io_url}, HTTP_HOST="openzaak.nl"
        )

        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.data), 1)
        self.assertEqual(response.data[0]["informatieobject"], io_url)
Esempio n. 12
0
    def test_create_bio_external_document(self):
        document = f"{self.base}enkelvoudiginformatieobjecten/{uuid.uuid4()}"
        besluit = BesluitFactory.create(besluittype__concept=False)
        besluit_url = f"http://openzaak.nl{reverse(besluit)}"
        informatieobjecttype = InformatieObjectTypeFactory.create(
            catalogus=besluit.besluittype.catalogus, concept=False
        )
        informatieobjecttype_url = f"http://openzaak.nl{reverse(informatieobjecttype)}"
        informatieobjecttype.besluittypen.add(besluit.besluittype)
        eio_response = get_eio_response(
            document, informatieobjecttype=informatieobjecttype_url
        )
        oio_response = get_oio_response(document, besluit_url, "besluit")

        with self.subTest(section="bio-create"):
            with requests_mock.Mocker(real_http=True) as m:
                mock_service_oas_get(m, APITypes.drc, self.base)
                m.get(document, json=eio_response)
                m.post(
                    "https://external.documenten.nl/api/v1/objectinformatieobjecten",
                    json=oio_response,
                    status_code=201,
                )

                response = self.client.post(
                    self.list_url,
                    {"besluit": besluit_url, "informatieobject": document},
                )

            self.assertEqual(
                response.status_code, status.HTTP_201_CREATED, response.data
            )
            posts = [req for req in m.request_history if req.method == "POST"]
            self.assertEqual(len(posts), 1)
            request = posts[0]
            self.assertEqual(
                request.url,
                "https://external.documenten.nl/api/v1/objectinformatieobjecten",
            )
            self.assertEqual(
                request.json(),
                {
                    "informatieobject": document,
                    "object": besluit_url,
                    "objectType": "besluit",
                },
            )

            self.assertFalse(ObjectInformatieObject.objects.exists())

            bio = BesluitInformatieObject.objects.get()
            self.assertEqual(bio._objectinformatieobject_url, oio_response["url"])

        with self.subTest(section="bio-list"):
            list_response = self.client.get(
                self.list_url, {"besluit": besluit_url}, HTTP_HOST="openzaak.nl",
            )

            self.assertEqual(
                list_response.status_code, status.HTTP_200_OK, response.data
            )
            data = list_response.json()

            self.assertEqual(len(data), 1)
            self.assertEqual(data[0]["informatieobject"], document)
    def test_relate_external_document(self):
        base = "https://external.documenten.nl/api/v1/"
        document = f"{base}enkelvoudiginformatieobjecten/{uuid.uuid4()}"
        zio_type = ZaakTypeInformatieObjectTypeFactory.create(
            informatieobjecttype__concept=False, zaaktype__concept=False
        )
        zaak = ZaakFactory.create(zaaktype=zio_type.zaaktype)
        zaak_url = f"http://openzaak.nl{reverse(zaak)}"
        eio_response = get_eio_response(
            document,
            informatieobjecttype=f"http://testserver{reverse(zio_type.informatieobjecttype)}",
        )
        oio_response = get_oio_response(document, zaak_url)

        with self.subTest(section="zio-create"):
            with requests_mock.Mocker(real_http=True) as m:
                m.get(document, json=eio_response)
                m.post(
                    "https://external.documenten.nl/api/v1/objectinformatieobjecten",
                    json=oio_response,
                    status_code=201,
                )

                response = self.client.post(
                    reverse(ZaakInformatieObject),
                    {"zaak": zaak_url, "informatieobject": document},
                )

            self.assertEqual(
                response.status_code, status.HTTP_201_CREATED, response.data
            )

            posts = [req for req in m.request_history if req.method == "POST"]
            self.assertEqual(len(posts), 1)
            request = posts[0]
            self.assertEqual(
                request.url,
                "https://external.documenten.nl/api/v1/objectinformatieobjecten",
            )
            self.assertEqual(
                request.json(),
                {
                    "informatieobject": document,
                    "object": zaak_url,
                    "objectType": "zaak",
                },
            )

            self.assertFalse(ObjectInformatieObject.objects.exists())

            zio = ZaakInformatieObject.objects.get()
            self.assertEqual(zio._objectinformatieobject_url, oio_response["url"])

        with self.subTest(section="zio-list"):
            list_response = self.client.get(
                reverse(ZaakInformatieObject),
                {"zaak": zaak_url},
                HTTP_HOST="openzaak.nl",
            )

            self.assertEqual(list_response.status_code, status.HTTP_200_OK)
            data = list_response.json()

            self.assertEqual(len(data), 1)
            self.assertEqual(data[0]["informatieobject"], document)