def test_put_besluit_not_allowed(self):
        io = EnkelvoudigInformatieObjectFactory.create()
        io_url = io.get_url()
        self.adapter.get(io_url, json=serialise_eio(io, io_url))
        self.create_zaak_besluit_services()
        besluit = self.create_besluit()
        bio = BesluitInformatieObjectFactory.create(informatieobject=io_url,
                                                    besluit=besluit)
        bio_detail_url = reverse(bio)
        besluit = BesluitFactory.create()
        besluit_url = reverse(besluit)
        io = EnkelvoudigInformatieObjectFactory.create()
        io_url = reverse(io)

        response = self.client.put(
            bio_detail_url,
            {
                "besluit": f"http://testserver{besluit_url}",
                "informatieobject": f"http://testserver{io_url}",
            },
        )

        self.assertEqual(response.status_code,
                         status.HTTP_405_METHOD_NOT_ALLOWED, response.data)
Ejemplo n.º 2
0
    def test_informatieobject_create(self):
        site = Site.objects.get_current()
        self.create_zaak_besluit_services()
        zaak = self.create_zaak()
        zaak_url = reverse(zaak)
        io = EnkelvoudigInformatieObjectFactory.create(
            informatieobjecttype__concept=False)
        io_url = f"http://testserver{reverse(io)}"
        self.adapter.get(io_url, json=serialise_eio(io, io_url))
        ZaakTypeInformatieObjectTypeFactory.create(
            informatieobjecttype=io.informatieobjecttype,
            zaaktype=zaak.zaaktype)

        url = reverse(ZaakInformatieObject)

        response = self.client.post(
            url,
            {
                "zaak": f"http://{site.domain}{zaak_url}",
                "informatieobject": io_url,
            },
        )

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
Ejemplo n.º 3
0
    def test_validate_no_informatieobjecttype_besluittype_relation(self):
        zaak = ZaakFactory.create()
        besluit = BesluitFactory.create(zaak=zaak)
        besluit_url = reverse(besluit)
        io = EnkelvoudigInformatieObjectFactory.create()
        io_url = reverse(io)
        self.adapter.get(io_url, json=serialise_eio(io, io_url))

        url = reverse("besluitinformatieobject-list")

        response = self.client.post(
            url,
            {
                "besluit": f"http://testserver{besluit_url}",
                "informatieobject": f"http://testserver{io_url}",
            },
        )

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(
            error["code"], "missing-besluittype-informatieobjecttype-relation"
        )
Ejemplo n.º 4
0
    def test_us162_voeg_besluit_toe_aan_zaak(self):
        self.create_zaak_besluit_services()
        zaak = self.create_zaak(zaaktype__concept=False)
        zaak_url = reverse(zaak)
        besluittype = BesluitTypeFactory.create(concept=False)
        besluittype_url = reverse(besluittype)
        besluittype.zaaktypen.add(zaak.zaaktype)
        io = EnkelvoudigInformatieObjectFactory.create(
            informatieobjecttype__concept=False
        )
        io_url = reverse(io)
        self.adapter.get(io_url, json=serialise_eio(io, io_url))
        besluittype.informatieobjecttypen.add(io.informatieobjecttype)

        # Mocking the besluit
        besluit_data = {
            "verantwoordelijke_organisatie": "517439943",  # RSIN
            "identificatie": "123123",
            "besluittype": f"http://testserver{besluittype_url}",
            "zaak": f"http://testserver{zaak_url}",
            "datum": "2018-09-06",
            "toelichting": "Vergunning verleend.",
            "ingangsdatum": "2018-10-01",
            "vervaldatum": "2018-11-01",
            "vervalreden": VervalRedenen.tijdelijk,
        }
        mock_service_oas_get(self.adapter, APITypes.brc, self.base_besluit)
        matcher = re.compile("besluiten/api/v1/.+?-.+?-.+?-.+?-.+?")
        self.adapter.register_uri("GET", matcher, json=besluit_data)

        with self.subTest(part="besluit_create"):
            url = get_operation_url("besluit_create")

            response = self.client.post(url, besluit_data,)

            self.assertEqual(
                response.status_code, status.HTTP_201_CREATED, response.data
            )
            self.assertResponseTypes(
                response.data,
                (
                    ("url", str),
                    ("identificatie", str),
                    ("verantwoordelijke_organisatie", str),
                    ("besluittype", str),
                    ("zaak", str),
                    ("datum", str),
                    ("toelichting", str),
                    ("bestuursorgaan", str),
                    ("ingangsdatum", str),
                    ("vervaldatum", str),
                    ("vervalreden", str),
                    ("publicatiedatum", type(None)),
                    ("verzenddatum", type(None)),
                    ("uiterlijke_reactiedatum", type(None)),
                ),
            )

            self.assertEqual(Besluit.objects.count(), 1)

            besluit = Besluit.objects.get()
            self.assertEqual(besluit.verantwoordelijke_organisatie, "517439943")
            self.assertEqual(besluit.besluittype, besluittype)
            self.assertEqual(besluit.zaak, zaak)
            self.assertEqual(besluit.datum, date(2018, 9, 6))
            self.assertEqual(besluit.toelichting, "Vergunning verleend.")
            self.assertEqual(besluit.ingangsdatum, date(2018, 10, 1))
            self.assertEqual(besluit.vervaldatum, date(2018, 11, 1))
            self.assertEqual(besluit.vervalreden, VervalRedenen.tijdelijk)

        with self.subTest(part="besluitinformatieobject_create"):
            url = get_operation_url("besluitinformatieobject_create")

            response = self.client.post(
                url,
                {
                    "besluit": f"http://testserver{reverse(besluit)}",
                    "informatieobject": f"http://testserver{io_url}",
                },
            )

            self.assertEqual(
                response.status_code, status.HTTP_201_CREATED, response.data
            )
            self.assertResponseTypes(
                response.data, (("url", str), ("informatieobject", str))
            )

            self.assertEqual(besluit.besluitinformatieobject_set.count(), 1)

            self.assertEqual(
                besluit.besluitinformatieobject_set.get().informatieobject.uuid,
                io.uuid,
            )