def test_meerdere_coordinatoren_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,
                          rolomschrijving=RolOmschrijving.zaakcoordinator)
        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,
                'rolomschrijving': RolOmschrijving.zaakcoordinator,
                'roltoelichting': 'Melder',
            })

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
예제 #2
0
    def test_meerdere_coordinatoren_verboden(self, *mocks):
        """
        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(zaaktype=ZAAKTYPE)
        RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.natuurlijk_persoon,
            omschrijving=RolOmschrijving.zaakcoordinator,
            omschrijving_generiek=RolOmschrijving.zaakcoordinator,
        )
        zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid)
        url = get_operation_url("rol_create")

        with requests_mock.Mocker() as m:
            m.get(ROLTYPE3, json=ROLTYPE3_RESPONSE)
            with mock_client({ROLTYPE3: ROLTYPE3_RESPONSE}):
                response = self.client.post(
                    url,
                    {
                        "zaak": zaak_url,
                        "betrokkene": WATERNET,
                        "betrokkeneType": RolTypes.organisatorische_eenheid,
                        "roltype": ROLTYPE3,
                        "roltoelichting": "Melder",
                    },
                )

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
    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)
    def test_list_rol_limited_to_authorized_zaken(self):
        url = reverse('rol-list')
        # must show up
        rol = RolFactory.create(
            zaak__zaaktype='https://zaaktype.nl/ok',
            zaak__vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduiding.
            openbaar)
        # must not show up
        RolFactory.create(
            zaak__zaaktype='https://zaaktype.nl/ok',
            zaak__vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduiding.
            vertrouwelijk)
        # must not show up
        RolFactory.create(
            zaak__zaaktype='https://zaaktype.nl/not_ok',
            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)}")
예제 #5
0
    def test_delete_zaak_cascades_properly(self):
        """
        Deleting a zaak causes all related objects to be deleted as well.
        """
        zaak = ZaakFactory.create(zaaktype=ZAAKTYPE)

        ZaakFactory.create(hoofdzaak=zaak, zaaktype=ZAAKTYPE)

        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)
예제 #6
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()["results"]

        self.assertEqual(len(data), 1)
        self.assertEqual(data[0]["betrokkeneIdentificatie"]["inpBsn"],
                         "183068142")
예제 #7
0
    def test_conditional_get_304(self):
        rol = RolFactory.create(with_etag=True)

        response = self.client.get(reverse(rol),
                                   HTTP_IF_NONE_MATCH=f'"{rol._etag}"')

        self.assertEqual(response.status_code, status.HTTP_304_NOT_MODIFIED)
예제 #8
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)
        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": rol.roltype,
                "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": "",
                    },
                },
            },
        )
예제 #9
0
    def test_rollen(self):
        rol = RolFactory.create(zaak=self.zaak, roltype=ROLTYPE)
        rol_url = reverse(rol)

        create_url = reverse(Rol)
        data = {
            "zaak": reverse(self.zaak),
            "roltype": ROLTYPE,
            "betrokkeneType": "vestiging",
            "betrokkene": "https://example.com",
            "roltoelichting": "foo",
        }

        self.assertCreateAllowed(create_url, data)
        self.assertDestroyAllowed(rol_url)
예제 #10
0
    def test_read_rol_np(self):
        zaak = ZaakFactory.create()
        rol = RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.natuurlijk_persoon,
            betrokkene=
            'http://www.zamora-silva.org/api/betrokkene/8768c581-2817-4fe5-933d-37af92d819dd',
            rolomschrijving='Beslisser')
        NatuurlijkPersoon.objects.create(
            rol=rol,
            nummer_ander_natuurlijk_persoon='12345',
        )
        zaak_url = get_operation_url('zaak_read', uuid=zaak.uuid)
        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}',
                'zaak': f'http://testserver{zaak_url}',
                'betrokkene': BETROKKENE,
                'betrokkeneType': RolTypes.natuurlijk_persoon,
                'rolomschrijving': 'Beslisser',
                'roltoelichting': '',
                'betrokkeneIdentificatie': {
                    'burgerservicenummer': '',
                    'nummerAnderNatuurlijkPersoon': '12345',
                    'aNummer': '',
                    'geslachtsnaam': '',
                    'voorvoegselGeslachtsnaam': '',
                    'voorletters': '',
                    'voornamen': '',
                    'geslachtsaanduiding': '',
                    'geboortedatum': '',
                    'verblijfsadres': '',
                    'subVerblijfBuitenland': ''
                }
            })
예제 #11
0
    def test_read_rol_nnp(self):
        zaak = ZaakFactory.create()
        rol = RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.niet_natuurlijk_persoon,
            betrokkene=BETROKKENE,
            rolomschrijving='Beslisser')
        NietNatuurlijkPersoon.objects.create(
            rol=rol,
            nummer_ander_nietnatuurlijk_persoon='123456',
        )
        zaak_url = get_operation_url('zaak_read', uuid=zaak.uuid)
        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}',
                'zaak': f'http://testserver{zaak_url}',
                'betrokkene': BETROKKENE,
                'betrokkeneType': RolTypes.niet_natuurlijk_persoon,
                'rolomschrijving': 'Beslisser',
                'roltoelichting': '',
                'betrokkeneIdentificatie': {
                    'rsin': '',
                    'nummerAnderNietnatuurlijkPersoon': '123456',
                    'statutaireNaam': '',
                    'rechtsvorm': '',
                    'bezoekadres': '',
                    'subVerblijfBuitenland': ''
                }
            })
예제 #12
0
    def test_conditional_get_stale(self):
        rol = RolFactory.create(with_etag=True)

        response = self.client.get(reverse(rol), HTTP_IF_NONE_MATCH='"old"')

        self.assertEqual(response.status_code, status.HTTP_200_OK)
예제 #13
0
    def test_rol_head_cache_header(self):
        rol = RolFactory.create()

        self.assertHeadHasETag(reverse(rol))
예제 #14
0
    def test_rol_get_cache_header(self):
        rol = RolFactory.create()

        response = self.client.get(reverse(rol))

        self.assertHasETag(response)
예제 #15
0
    def test_read_rol_np(self):
        zaak = ZaakFactory.create()
        rol = RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.natuurlijk_persoon,
            betrokkene=
            "http://www.zamora-silva.org/api/betrokkene/8768c581-2817-4fe5-933d-37af92d819dd",
            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)
        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": rol.roltype,
                "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": "",
                    },
                },
            },
        )
예제 #16
0
    def test_read_rol_vestiging(self):
        zaak = ZaakFactory.create()
        rol = RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.vestiging,
            betrokkene=BETROKKENE,
            omschrijving="Beslisser",
            omschrijving_generiek="Beslisser",
            indicatie_machtiging=IndicatieMachtiging.gemachtigde,
        )
        vestiging = Vestiging.objects.create(rol=rol,
                                             vestigings_nummer="123456")
        Adres.objects.create(
            vestiging=vestiging,
            identificatie="123",
            postcode="1111",
            wpl_woonplaats_naam="test city",
            gor_openbare_ruimte_naam="test",
            huisnummer=1,
        )
        SubVerblijfBuitenland.objects.create(
            vestiging=vestiging,
            lnd_landcode="UK",
            lnd_landnaam="United Kingdom",
            sub_adres_buitenland_1="some uk adres",
        )
        zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid)
        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.vestiging,
                "roltype": rol.roltype,
                "omschrijving": "Beslisser",
                "omschrijvingGeneriek": "Beslisser",
                "roltoelichting": "",
                "registratiedatum": "2018-01-01T00:00:00Z",
                "indicatieMachtiging": "gemachtigde",
                "betrokkeneIdentificatie": {
                    "vestigingsNummer": "123456",
                    "handelsnaam": [],
                    "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": "",
                    },
                },
            },
        )