Ejemplo n.º 1
0
    def test_filter_subject_niet_natuurlijk_persoon_anp_identificatie(self):
        klant1, klant2 = KlantFactory.create_batch(
            2, subject="", subject_type=KlantType.niet_natuurlijk_persoon)
        NietNatuurlijkPersoonFactory.create(ann_identificatie="123",
                                            klant=klant1)
        NietNatuurlijkPersoonFactory.create(ann_identificatie="321",
                                            klant=klant2)

        url = reverse(Klant)

        response = self.client.get(
            url, {"subject_nietNatuurlijkPersoon__annIdentificatie": "123"})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        response_data = response.json()
        self.assertEqual(response_data["count"], 1)

        result = response_data["results"][0]
        self.assertEqual(result["subjectIdentificatie"]["annIdentificatie"],
                         "123")
    def test_filter(self):
        oio = ObjectInformatieObjectFactory.create(is_zaak=True)
        eo_detail_url = reverse(
            "enkelvoudiginformatieobject-detail",
            kwargs={"uuid": oio.informatieobject.latest_version.uuid},
        )

        response = self.client.get(
            self.list_url,
            {"informatieobject": f"http://testserver.com{eo_detail_url}"},
            HTTP_HOST="testserver.com",
        )

        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.data), 1)
        self.assertEqual(
            response.data[0]["informatieobject"],
            f"http://testserver.com{eo_detail_url}",
        )
Ejemplo n.º 3
0
    def test_lock_success(self):
        eio = EnkelvoudigInformatieObjectFactory.create()
        canonical = eio.canonical

        assert canonical.lock == ""

        lock_url = reverse("enkelvoudiginformatieobject-lock",
                           kwargs={"uuid": eio.uuid})

        lock_response = self.client.post(lock_url)
        self.assertEqual(lock_response.status_code, status.HTTP_200_OK)

        data = lock_response.json()

        eio = EnkelvoudigInformatieObject.objects.get(uuid=eio.uuid)
        canonical = eio.canonical

        self.assertEqual(data["lock"], canonical.lock)
        self.assertNotEqual(data["lock"], "")
Ejemplo n.º 4
0
    def test_filter_by_valid_url_object_does_not_exist(self):
        besluittype = BesluitTypeFactory.create(concept=False)
        besluittype.zaaktypen.clear()
        besluittype.informatieobjecttypen.clear()
        for query_param in ["catalogus", "zaaktypen", "informatieobjecttypen"]:
            with self.subTest(query_param=query_param):
                response = self.client.get(reverse(BesluitType),
                                           {query_param: "https://google.com"})

                self.assertEqual(response.status_code, status.HTTP_200_OK)
                self.assertEqual(
                    response.data,
                    {
                        "count": 0,
                        "next": None,
                        "previous": None,
                        "results": []
                    },
                )
Ejemplo n.º 5
0
    def test_trigger_deploy(self, mock_deploy):
        url = reverse("deployment-list")

        body = {
            "name": "zrc",
            "namespace": "zgw",
            "container_name": "zrc",
            "image": "vngr/gemma-zrc:latest",
        }
        response = self.client.post(url, body)

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

        mock_deploy.assert_called_once_with(
            name="zrc",
            namespace="zgw",
            container_name="zrc",
            image="vngr/gemma-zrc:latest",
        )
    def test_filter_by_informatieobject(self):
        eio = EnkelvoudigInformatieObjectFactory.create()
        eio_url = f"http://openzaak.nl{reverse(eio)}"
        self.adapter.get(eio_url, json=serialise_eio(eio, eio_url))
        self.create_zaak_besluit_services()
        zaak = self.create_zaak()
        ZaakInformatieObjectFactory.create(informatieobject=eio_url, zaak=zaak)

        zio_list_url = reverse("zaakinformatieobject-list")

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

        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.data), 1)
        self.assertEqual(response.data[0]["informatieobject"], eio_url)
Ejemplo n.º 7
0
    def test_create_external_roltype_fail_not_json_url(self):
        zaak = ZaakFactory.create()
        zaak_url = reverse(zaak)

        response = self.client.post(
            self.list_url,
            {
                "zaak": f"http://testserver{zaak_url}",
                "betrokkene": BETROKKENE,
                "betrokkene_type": RolTypes.natuurlijk_persoon,
                "roltype": "http://example.com",
                "roltoelichting": "awerw",
            },
        )

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

        error = get_validation_errors(response, "roltype")
        self.assertEqual(error["code"], "invalid-resource")
    def test_bestandsomvang(self):
        """
        Assert that the API shows the filesize.
        """
        test_object = EnkelvoudigInformatieObjectFactory.create(
            inhoud__data=b'some content')

        # Retrieve from the API
        detail_url = reverse('enkelvoudiginformatieobject-detail',
                             kwargs={
                                 'version': '1',
                                 'uuid': test_object.uuid,
                             })

        response = self.client.get(detail_url)

        # Test response
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['bestandsomvang'], 12)  # 12 bytes
    def test_bestandsomvang(self):
        """
        Assert that the API shows the filesize.
        """
        test_object = EnkelvoudigInformatieObjectFactory.create(
            inhoud__data=b"some content"
        )

        # Retrieve from the API
        detail_url = reverse(
            "enkelvoudiginformatieobject-detail",
            kwargs={"version": "1", "uuid": test_object.uuid},
        )

        response = self.client.get(detail_url)

        # Test response
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data["bestandsomvang"], 12)  # 12 bytes
Ejemplo n.º 10
0
    def test_send_notif_create_enkelvoudiginformatieobject(self, mock_client):
        """
        Registreer een ENKELVOUDIGINFORMATIEOBJECT
        """
        informatieobjecttype = InformatieObjectTypeFactory.create(concept=False)
        informatieobjecttype_url = reverse(informatieobjecttype)
        client = mock_client.return_value
        url = get_operation_url("enkelvoudiginformatieobject_create")
        data = {
            "identificatie": "AMS20180701001",
            "bronorganisatie": "159351741",
            "creatiedatum": "2018-07-01",
            "titel": "text_extra.txt",
            "auteur": "ANONIEM",
            "formaat": "text/plain",
            "taal": "dut",
            "inhoud": base64.b64encode(b"Extra tekst in bijlage").decode("utf-8"),
            "informatieobjecttype": f"http://testserver{informatieobjecttype_url}",
            "vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduiding.openbaar,
        }

        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()
        client.create.assert_called_once_with(
            "notificaties",
            {
                "kanaal": "documenten",
                "hoofdObject": data["url"],
                "resource": "enkelvoudiginformatieobject",
                "resourceUrl": data["url"],
                "actie": "create",
                "aanmaakdatum": "2012-01-14T00:00:00Z",
                "kenmerken": {
                    "bronorganisatie": "159351741",
                    "informatieobjecttype": f"http://testserver{informatieobjecttype_url}",
                    "vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduiding.openbaar,
                },
            },
        )
Ejemplo n.º 11
0
    def test_list_gebruiksrechten_no_url_mapping(self):
        for i in range(2):
            eio = EnkelvoudigInformatieObjectFactory.create()
            eio_url = f"http://testserver{reverse(eio)}"
            GebruiksrechtenCMISFactory(informatieobject=eio_url)

        url = reverse("gebruiksrechten-list")

        # Remove all available mappings
        UrlMapping.objects.all().delete()

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST,
                         response.data)
        self.assertEqual(
            response.data["detail"],
            "CMIS-adapter could not shrink one of the URL fields.",
        )
Ejemplo n.º 12
0
    def test_create_zaakeigenschap_not_in_zaaktypen_fails(self):
        zaak = ZaakFactory.create()
        eigenschap = EigenschapFactory.create(eigenschapnaam="foobar")
        url = get_operation_url("zaakeigenschap_create", zaak_uuid=zaak.uuid)
        zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid)
        eigenschap_url = reverse(eigenschap)
        data = {
            "zaak": zaak_url,
            "eigenschap": f"http://testserver{eigenschap_url}",
            "waarde": "overlast_water",
        }

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

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], "zaaktype-mismatch")
Ejemplo n.º 13
0
    def test_get_detail(self):
        response = self.api_client.get(self.zaakobjecttype_detail_url)
        self.assertEqual(response.status_code, 200)

        expected = {
            "anderObject": "",
            "einddatumObject": None,
            "ingangsdatumObject": "2018-01-01",
            "isRelevantVoor": "http://testserver{}".format(
                reverse(
                    "zaaktype-detail",
                    args=[self.API_VERSION, self.catalogus.pk, self.zaaktype.pk],
                )
            ),
            "objecttype": "",
            "relatieOmschrijving": "",
            "url": "http://testserver{}".format(self.zaakobjecttype_detail_url),
        }
        self.assertEqual(expected, response.json())
    def test_besluit_create_fail_send_notification_create_db_entry(self):
        besluittype = BesluitTypeFactory.create(concept=False)
        besluittype_url = reverse(besluittype)
        url = get_operation_url("besluit_create")
        data = {
            "verantwoordelijkeOrganisatie": "517439943",  # RSIN
            "besluittype": f"http://testserver{besluittype_url}",
            "identificatie": "123123",
            "datum": "2018-09-06",
            "toelichting": "Vergunning verleend.",
            "ingangsdatum": "2018-10-01",
            "vervaldatum": "2018-11-01",
            "vervalreden": VervalRedenen.tijdelijk,
        }

        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": data["url"],
            "kanaal": "besluiten",
            "kenmerken": {
                "verantwoordelijkeOrganisatie":
                data["verantwoordelijkeOrganisatie"],
                "besluittype":
                f"http://testserver{besluittype_url}",
            },
            "resource": "besluit",
            "resourceUrl": data["url"],
        }

        self.assertEqual(failed.statuslog_ptr, logged_warning)
        self.assertEqual(failed.message, message)
Ejemplo n.º 15
0
    def test_create_external_eigenschap_fail_bad_url(self):
        zaak = ZaakFactory()
        zaak_url = reverse(zaak)
        url = get_operation_url("zaakeigenschap_list", zaak_uuid=zaak.uuid)

        response = self.client.post(
            url,
            {
                "zaak": zaak_url,
                "eigenschap": "abcd",
                "waarde": "overlast_water",
            },
        )

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

        error = get_validation_errors(response, "eigenschap")
        self.assertEqual(error["code"], "bad-url")
    def test_list_contactmomenten_filter_vorig_contactmoment(self):
        list_url = reverse(ContactMoment)
        cmc1, cmc2, cmc3 = ContactMomentFactory.create_batch(3)
        cmc3.vorig_contactmoment = cmc2
        cmc3.save()

        response = self.client.get(
            list_url,
            {"vorigContactmoment": f"http://testserver.com{reverse(cmc2)}"},
            HTTP_HOST="testserver.com",
        )

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

        self.assertEqual(len(response.data["results"]), 1)
        self.assertEqual(
            response.data["results"][0]["vorig_contactmoment"],
            f"http://testserver.com{reverse(cmc2)}",
        )
Ejemplo n.º 17
0
    def test_partial_update_informatieobjecttype_related_to_non_concept_zaaktype_fails(
        self, ):
        catalogus = CatalogusFactory.create()
        informatieobjecttype = InformatieObjectTypeFactory.create(
            catalogus=catalogus)
        zaaktype = ZaakTypeFactory.create(catalogus=catalogus, concept=False)
        ZaakTypeInformatieObjectTypeFactory(
            zaaktype=zaaktype, informatieobjecttype=informatieobjecttype)

        informatieobjecttype_url = reverse(informatieobjecttype)

        response = self.client.patch(informatieobjecttype_url,
                                     {"omschrijving": "aangepast"})

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], M2MConceptUpdateValidator.code)
        informatieobjecttype.delete()
    def test_get_resultaat(self):
        """
        test resultaat get api:
        bewaartermijn is displayed correctly
        procestermijn_opmerking is displayed correctly
        """
        resultaat = ResultaatFactory.create(
            bewaartermijn=relativedelta(years=10),
            procestermijn_opmerking="5 of 10 jaar",
        )
        url = reverse("resultaat-detail", kwargs={"uuid": resultaat.uuid})

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        response_data = response.json()
        self.assertEqual(response_data["bewaartermijn"], "P10Y")
        self.assertEqual(response_data["procestermijnOpmerking"],
                         "5 of 10 jaar")
Ejemplo n.º 19
0
    def test_validate_verlenging(self):
        """
        Regression test
        """
        zaak = ZaakFactory.create()
        zaak_url = reverse(zaak)

        response = self.client.patch(
            zaak_url,
            {
                "verlenging": {
                    "reden": "We hebben nog tijd genoeg",
                    "duur": "P0Y1M0D"
                }
            },
            **ZAAK_WRITE_KWARGS,
        )

        self.assertEqual(response.status_code, status.HTTP_200_OK)
Ejemplo n.º 20
0
    def test_eio_list(self):
        EnkelvoudigInformatieObjectFactory.create(
            informatieobjecttype=self.informatieobjecttype,
            vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduiding.openbaar,
        )
        EnkelvoudigInformatieObjectFactory.create(
            informatieobjecttype=
            "https://externe.catalogus.nl/api/v1/informatieobjecttypen/1",
            vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduiding.openbaar,
        )
        url = reverse("enkelvoudiginformatieobject-list")

        response = self.client.get(url)

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

        results = response.data["results"]
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0]["informatieobjecttype"], IOTYPE_EXTERNAL)
Ejemplo n.º 21
0
    def test_cannot_read_without_correct_scope(self):
        zaak = ZaakFactory.create()
        status = StatusFactory.create()
        zaak_object = ZaakObjectFactory.create()
        resultaat = ResultaatFactory.create()
        urls = [
            reverse("zaak-list"),
            reverse(zaak),
            reverse("status-list"),
            reverse(status),
            reverse("resultaat-list"),
            reverse(resultaat),
            reverse("zaakobject-list"),
            reverse(zaak_object),
        ]

        for url in urls:
            with self.subTest(url=url):
                self.assertForbidden(url,
                                     method="get",
                                     request_kwargs=ZAAK_READ_KWARGS)
Ejemplo n.º 22
0
    def test_block_clearing_indication(self):
        """
        If gebruiksrechten exist, you cannot change the indicatieGebruiksrechten
        anymore.
        """
        gebruiksrechten = GebruiksrechtenFactory.create()

        url = reverse(
            "enkelvoudiginformatieobject-detail",
            kwargs={"uuid": gebruiksrechten.get_informatieobject().uuid},
        )

        for invalid_value in (None, False):
            data = {"indicatieGebruiksrecht": invalid_value}
            response = self.client.patch(url, data)

            self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
            error = get_validation_errors(response, "indicatieGebruiksrecht")
            self.assertEqual(error["code"], "existing-gebruiksrechten")
Ejemplo n.º 23
0
    def test_partial_update_informatieobjecttype_einde_geldigheid_related_to_non_concept_besluittype(
        self, ):
        catalogus = CatalogusFactory.create()
        informatieobjecttype = InformatieObjectTypeFactory.create(
            catalogus=catalogus)
        BesluitTypeFactory.create(
            informatieobjecttypen=[informatieobjecttype],
            catalogus=catalogus,
            concept=False,
        )

        informatieobjecttype_url = reverse(informatieobjecttype)

        response = self.client.patch(informatieobjecttype_url,
                                     {"eindeGeldigheid": "2020-01-01"})

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data["einde_geldigheid"], "2020-01-01")
        informatieobjecttype.delete()
Ejemplo n.º 24
0
    def test_zaak_met_producten(self):
        url = reverse("zaak-list")
        self.zaaktype.producten_of_diensten = [
            "https://example.com/product/123",
            "https://example.com/dienst/123",
        ]
        self.zaaktype.save()

        response = self.client.post(
            url,
            {
                "zaaktype": f"http://testserver{self.zaaktype_url}",
                "vertrouwelijkheidaanduiding":
                VertrouwelijkheidsAanduiding.openbaar,
                "bronorganisatie": "517439943",
                "verantwoordelijkeOrganisatie": "517439943",
                "registratiedatum": "2018-12-24",
                "startdatum": "2018-12-24",
                "productenOfDiensten": ["https://example.com/product/123"],
            },
            **ZAAK_WRITE_KWARGS,
        )

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        zaak = Zaak.objects.get()
        self.assertEqual(len(zaak.producten_of_diensten), 1)

        # update
        response2 = self.client.patch(
            response.data["url"],
            {
                "productenOfDiensten": [
                    "https://example.com/product/123",
                    "https://example.com/dienst/123",
                ]
            },
            **ZAAK_WRITE_KWARGS,
        )

        self.assertEqual(response2.status_code, status.HTTP_200_OK)
        zaak.refresh_from_db()
        self.assertEqual(len(zaak.producten_of_diensten), 2)
    def test_create_fail_informatieobjecttype_max_length(self):
        informatieobjecttype = InformatieObjectTypeFactory.create()
        informatieobjecttype_url = reverse(informatieobjecttype)
        content = {
            "identificatie":
            uuid.uuid4().hex,
            "bronorganisatie":
            "159351741",
            "creatiedatum":
            "2018-06-27",
            "titel":
            "detailed summary",
            "auteur":
            "test_auteur",
            "formaat":
            "txt",
            "taal":
            "eng",
            "bestandsnaam":
            "dummy.txt",
            "inhoud":
            b64encode(b"some file content").decode("utf-8"),
            "link":
            "http://een.link",
            "beschrijving":
            "test_beschrijving",
            "informatieobjecttype":
            f"http://testserver/some-very-long-url-addres-which-exceeds-maximum-"
            f"length-of-hyperlinkedrelatedfield/aaaaaaaaaaaaaaaaaaaaaaaaa/"
            f"{informatieobjecttype_url}",
            "vertrouwelijkheidaanduiding":
            "openbaar",
        }

        # Send to the API
        response = self.client.post(self.list_url, content)

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

        error = get_validation_errors(response, "informatieobjecttype")
        self.assertEqual(error["code"], "max_length")
    def test_handle_create_auth(self):
        config = AuthorizationsConfig.get_solo()
        uuid = _uuid.uuid4()
        applicatie_url = f"{config.api_root}/applicaties/{uuid}"
        webhook_url = reverse("notificaties-webhook")

        responses = {
            applicatie_url: {
                "client_ids": ["id1"],
                "label":
                "Melding Openbare Ruimte consumer",
                "heeftAlleAutorisaties":
                False,
                "autorisaties": [{
                    "component":
                    "nrc",
                    "scopes": ["zaken.lezen", "zaken.aanmaken"],
                    "zaaktype":
                    "https://ref.tst.vng.cloud/zrc/api/v1/catalogus/1/zaaktypen/1",
                    "maxVertrouwelijkheidaanduiding":
                    VertrouwelijkheidsAanduiding.beperkt_openbaar,
                }],
            }
        }
        data = {
            "kanaal": "autorisaties",
            "hoofdObject": applicatie_url,
            "resource": "applicatie",
            "resourceUrl": applicatie_url,
            "actie": "create",
            "aanmaakdatum": "2012-01-14T00:00:00Z",
            "kenmerken": {},
        }
        with mock_client(responses):
            response = self.client.post(webhook_url, data)

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

        applicatie = Applicatie.objects.get(client_ids=["id1"])

        self.assertEqual(applicatie.uuid, uuid)
    def test_eio_update(self):
        eio = EnkelvoudigInformatieObjectFactory.create(
            beschrijving='beschrijving1',
            informatieobjecttype=INFORMATIEOBJECTTYPE,
        )

        eio_url = reverse('enkelvoudiginformatieobject-detail',
                          kwargs={
                              'uuid': eio.uuid,
                          })

        eio_response = self.client.get(eio_url)
        eio_data = eio_response.data

        lock = self.client.post(f'{eio_url}/lock').data['lock']
        eio_data.update({
            'beschrijving': 'beschrijving2',
            'inhoud': b64encode(b'aaaaa'),
            'lock': lock
        })

        for i in ['integriteit', 'ondertekening']:
            eio_data.pop(i)

        response = self.client.put(eio_url, eio_data)

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

        self.assertEqual(response_data['beschrijving'], 'beschrijving2')

        eios = EnkelvoudigInformatieObject.objects.filter(
            uuid=eio.uuid).order_by('-versie')
        self.assertEqual(len(eios), 2)

        latest_version = eios.first()
        self.assertEqual(latest_version.versie, 2)
        self.assertEqual(latest_version.beschrijving, 'beschrijving2')

        first_version = eios[1]
        self.assertEqual(first_version.versie, 1)
        self.assertEqual(first_version.beschrijving, 'beschrijving1')
Ejemplo n.º 28
0
    def test_create_rol_fail_validation(self):
        url = get_operation_url("rol_create")
        zaak = ZaakFactory.create()
        zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid)
        roltype = RolTypeFactory.create(zaaktype=zaak.zaaktype)
        roltype_url = reverse(roltype)
        data = {
            "zaak": f"http://testserver{zaak_url}",
            "betrokkene_type": RolTypes.natuurlijk_persoon,
            "roltype": f"http://testserver{roltype_url}",
            "roltoelichting": "awerw",
        }

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

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

        validation_error = get_validation_errors(response, "nonFieldErrors")

        self.assertEqual(validation_error["code"], "invalid-betrokkene")
    def test_delete(self):
        zio = ZaakInformatieObjectFactory.create(
            informatieobject=INFORMATIEOBJECT)
        zio_url = reverse("zaakinformatieobject-detail",
                          kwargs={
                              "version": "1",
                              "uuid": zio.uuid
                          })

        self.assertEqual(self.mocked_sync_delete.call_count, 0)

        response = self.client.delete(zio_url)
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT,
                         response.data)

        self.assertEqual(self.mocked_sync_delete.call_count, 1)

        # Relation is gone, zaak still exists.
        self.assertFalse(ZaakInformatieObject.objects.exists())
        self.assertTrue(Zaak.objects.exists())
Ejemplo n.º 30
0
    def test_delete_besluittype_related_to_non_concept_resource_fails(self):
        zaaktype = ZaakTypeFactory.create(concept=False)
        informatieobjecttype = InformatieObjectTypeFactory.create(
            concept=False)

        for resource in ["zaaktypen", "informatieobjecttypen"]:
            with self.subTest(resource=resource):
                related = zaaktype if resource == "zaaktypen" else informatieobjecttype
                besluittype = BesluitTypeFactory.create(
                    **{resource: [related]})
                besluittype_url = reverse("besluittype-detail",
                                          kwargs={"uuid": besluittype.uuid})

                response = self.client.delete(besluittype_url)

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

                error = get_validation_errors(response, "nonFieldErrors")
                self.assertEqual(error["code"], M2MConceptUpdateValidator.code)