def test_delete_zaak_cascades_properly(self):
        """
        Deleting a zaak causes all related objects to be deleted as well.
        """
        zaak = ZaakFactory.create()

        ZaakFactory.create(hoofdzaak=zaak)

        ZaakEigenschapFactory.create(zaak=zaak)
        StatusFactory.create(zaak=zaak)
        RolFactory.create(zaak=zaak)
        ResultaatFactory.create(zaak=zaak)
        ZaakObjectFactory.create(zaak=zaak)
        ZaakInformatieObjectFactory.create(zaak=zaak)
        KlantContactFactory.create(zaak=zaak)

        zaak_delete_url = get_operation_url("zaak_delete", uuid=zaak.uuid)

        response = self.client.delete(zaak_delete_url, **ZAAK_WRITE_KWARGS)
        self.assertEqual(
            response.status_code, status.HTTP_204_NO_CONTENT, response.data
        )

        self.assertEqual(Zaak.objects.all().count(), 0)

        self.assertEqual(ZaakEigenschap.objects.all().count(), 0)
        self.assertEqual(Status.objects.all().count(), 0)
        self.assertEqual(Rol.objects.all().count(), 0)
        self.assertEqual(Resultaat.objects.all().count(), 0)
        self.assertEqual(ZaakObject.objects.all().count(), 0)
        self.assertEqual(ZaakInformatieObject.objects.all().count(), 0)
        self.assertEqual(KlantContact.objects.all().count(), 0)
Beispiel #2
0
    def test_ophalen_alle_betrokkenen(self):
        """
        Test dat alle betrokkenen kunnen opgehaald worden, onafhankelijk van rol.

        Zie https://github.com/VNG-Realisatie/gemma-zaakregistratiecomponent/pull/9#issuecomment-407882637
        """
        zaak1 = ZaakFactory.create()
        rollen1 = RolFactory.create_batch(3, zaak=zaak1)
        rol2 = RolFactory.create()
        zaak_url = get_operation_url("zaak_read", uuid=zaak1.uuid)
        rollen_list_url = get_operation_url("rol_list")

        response = self.client.get(
            rollen_list_url, {"zaak": f"http://testserver{zaak_url}"}
        )

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

        self.assertEqual(len(response_data), 3)

        expected_urls = {
            f"http://testserver{get_operation_url('rol_read', uuid=rol.uuid)}"
            for rol in rollen1
        }

        received_urls = {rol["url"] for rol in response_data}
        self.assertEqual(received_urls, expected_urls)

        rol2_url = f"http://testserver{get_operation_url('rol_read', uuid=rol2.uuid)}"
        self.assertNotIn(rol2_url, received_urls)
Beispiel #3
0
    def test_filter_rol_np_bsn(self):
        zaak = ZaakFactory.create()
        rol = RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.natuurlijk_persoon,
            betrokkene="",
            omschrijving="Beslisser",
            omschrijving_generiek="Beslisser",
        )
        NatuurlijkPersoon.objects.create(rol=rol,
                                         inp_bsn="183068142",
                                         inp_a_nummer="1234567890")

        rol_2 = RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.natuurlijk_persoon,
            betrokkene="",
            omschrijving="Beslisser",
            omschrijving_generiek="Beslisser",
        )
        NatuurlijkPersoon.objects.create(rol=rol_2,
                                         inp_bsn="650237481",
                                         inp_a_nummer="2234567890")

        rol_3 = RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.vestiging,
            betrokkene="",
            omschrijving="Beslisser",
            omschrijving_generiek="Beslisser",
        )
        Vestiging.objects.create(rol=rol_3, vestigings_nummer="183068142")

        url = get_operation_url("rol_list", uuid=rol.uuid)

        response = self.client.get(url, {
            "betrokkeneIdentificatie__natuurlijkPersoon__inpBsn":
            "183068142"
        })

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

        data = response.json()

        self.assertEqual(len(data), 1)
        self.assertEqual(data[0]["betrokkeneIdentificatie"]["inpBsn"],
                         "183068142")
Beispiel #4
0
    def test_read_rol_nnp(self):
        zaak = ZaakFactory.create()
        rol = RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.niet_natuurlijk_persoon,
            betrokkene=BETROKKENE,
            omschrijving="Beslisser",
            omschrijving_generiek="Beslisser",
            indicatie_machtiging=IndicatieMachtiging.gemachtigde,
        )
        nietnaturlijkperson = NietNatuurlijkPersoon.objects.create(
            rol=rol, ann_identificatie="123456")
        SubVerblijfBuitenland.objects.create(
            nietnatuurlijkpersoon=nietnaturlijkperson,
            lnd_landcode="UK",
            lnd_landnaam="United Kingdom",
            sub_adres_buitenland_1="some uk adres",
        )
        zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid)
        roltype_url = reverse(rol.roltype)
        url = get_operation_url("rol_read", uuid=rol.uuid)

        response = self.client.get(url)

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

        data = response.json()

        self.assertEqual(
            data,
            {
                "url": f"http://testserver{url}",
                "uuid": str(rol.uuid),
                "zaak": f"http://testserver{zaak_url}",
                "betrokkene": BETROKKENE,
                "betrokkeneType": RolTypes.niet_natuurlijk_persoon,
                "roltype": f"http://testserver{roltype_url}",
                "omschrijving": "Beslisser",
                "omschrijvingGeneriek": "Beslisser",
                "roltoelichting": "",
                "registratiedatum": "2018-01-01T00:00:00Z",
                "indicatieMachtiging": "gemachtigde",
                "betrokkeneIdentificatie": {
                    "innNnpId": "",
                    "annIdentificatie": "123456",
                    "statutaireNaam": "",
                    "innRechtsvorm": "",
                    "bezoekadres": "",
                    "subVerblijfBuitenland": {
                        "lndLandcode": "UK",
                        "lndLandnaam": "United Kingdom",
                        "subAdresBuitenland_1": "some uk adres",
                        "subAdresBuitenland_2": "",
                        "subAdresBuitenland_3": "",
                    },
                },
            },
        )
Beispiel #5
0
    def test_list_rol_limited_to_authorized_zaken(self):
        url = reverse("rol-list")
        # must show up
        rol = RolFactory.create(
            zaak__zaaktype=self.zaaktype,
            zaak__vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduiding.openbaar,
        )
        # must not show up
        RolFactory.create(
            zaak__zaaktype=self.zaaktype,
            zaak__vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduiding.vertrouwelijk,
        )
        # must not show up
        RolFactory.create(
            zaak__vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduiding.openbaar
        )

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        response_data = response.json()
        self.assertEqual(len(response_data), 1)
        self.assertEqual(response_data[0]["url"], f"http://testserver{reverse(rol)}")
    def test_meerdere_initiatoren_verboden(self):
        """
        Uit RGBZ 2.0, deel 2, Attribuutsoort Rolomschrijving (bij relatieklasse
        ROL):

        Bij een ZAAK kan maximaal één ROL met als Rolomschrijving generiek
        'Initiator' voor komen.
        """
        zaak = ZaakFactory.create()
        RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.natuurlijk_persoon,
            omschrijving=RolOmschrijving.initiator,
            omschrijving_generiek=RolOmschrijving.initiator,
        )
        roltype = RolTypeFactory.create(
            omschrijving=RolOmschrijving.initiator,
            omschrijving_generiek=RolOmschrijving.initiator,
            zaaktype=zaak.zaaktype,
        )
        roltype_url = reverse(roltype)
        zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid)
        url = get_operation_url("rol_create")

        response = self.client.post(
            url,
            {
                "zaak": zaak_url,
                "betrokkene": WATERNET,
                "betrokkeneType": RolTypes.organisatorische_eenheid,
                "roltype": roltype_url,
                "roltoelichting": "Melder",
            },
        )

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
Beispiel #7
0
    def test_read_rol_np(self):
        zaak = ZaakFactory.create()
        rol = RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.natuurlijk_persoon,
            betrokkene=BETROKKENE,
            omschrijving="Beslisser",
            omschrijving_generiek="Beslisser",
            indicatie_machtiging=IndicatieMachtiging.gemachtigde,
        )
        naturlijkperson = NatuurlijkPersoon.objects.create(
            rol=rol, anp_identificatie="12345", inp_a_nummer="1234567890")
        Adres.objects.create(
            natuurlijkpersoon=naturlijkperson,
            identificatie="123",
            postcode="1111",
            wpl_woonplaats_naam="test city",
            gor_openbare_ruimte_naam="test",
            huisnummer=1,
        )
        SubVerblijfBuitenland.objects.create(
            natuurlijkpersoon=naturlijkperson,
            lnd_landcode="UK",
            lnd_landnaam="United Kingdom",
            sub_adres_buitenland_1="some uk adres",
        )
        zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid)
        roltype_url = reverse(rol.roltype)
        url = get_operation_url("rol_read", uuid=rol.uuid)

        response = self.client.get(url)

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

        data = response.json()

        self.assertEqual(
            data,
            {
                "url": f"http://testserver{url}",
                "uuid": str(rol.uuid),
                "zaak": f"http://testserver{zaak_url}",
                "betrokkene": BETROKKENE,
                "betrokkeneType": RolTypes.natuurlijk_persoon,
                "roltype": f"http://testserver{roltype_url}",
                "omschrijving": "Beslisser",
                "omschrijvingGeneriek": "Beslisser",
                "roltoelichting": "",
                "registratiedatum": "2018-01-01T00:00:00Z",
                "indicatieMachtiging": "gemachtigde",
                "betrokkeneIdentificatie": {
                    "inpBsn": "",
                    "anpIdentificatie": "12345",
                    "inpA_nummer": "1234567890",
                    "geslachtsnaam": "",
                    "voorvoegselGeslachtsnaam": "",
                    "voorletters": "",
                    "voornamen": "",
                    "geslachtsaanduiding": "",
                    "geboortedatum": "",
                    "verblijfsadres": {
                        "aoaIdentificatie": "123",
                        "wplWoonplaatsNaam": "test city",
                        "gorOpenbareRuimteNaam": "test",
                        "aoaPostcode": "1111",
                        "aoaHuisnummer": 1,
                        "aoaHuisletter": "",
                        "aoaHuisnummertoevoeging": "",
                        "inpLocatiebeschrijving": "",
                    },
                    "subVerblijfBuitenland": {
                        "lndLandcode": "UK",
                        "lndLandnaam": "United Kingdom",
                        "subAdresBuitenland_1": "some uk adres",
                        "subAdresBuitenland_2": "",
                        "subAdresBuitenland_3": "",
                    },
                },
            },
        )