Example #1
0
    def test_delete_ziot_not_concept_informatieobjecttype(self):
        ziot = ZaakInformatieobjectTypeFactory.create(
            informatieobjecttype__concept=False)
        ziot_url = reverse(ziot)

        response = self.client.delete(ziot_url)

        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
        self.assertFalse(ZaakInformatieobjectType.objects.filter(id=ziot.id))
    def test_conditional_get_304(self):
        zaakinformatieobjecttype = ZaakInformatieobjectTypeFactory.create(
            with_etag=True)
        response = self.client.get(
            reverse(zaakinformatieobjecttype),
            HTTP_IF_NONE_MATCH=f'"{zaakinformatieobjecttype._etag}"',
        )

        self.assertEqual(response.status_code, status.HTTP_304_NOT_MODIFIED)
Example #3
0
    def test_delete_ziot_fail_not_concept_zaaktype(self):
        ziot = ZaakInformatieobjectTypeFactory.create(zaaktype__concept=False)
        ziot_url = reverse(ziot)

        response = self.client.delete(ziot_url)

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

        data = response.json()
        self.assertEqual(data['detail'],
                         'Alleen concepten kunnen worden verwijderd.')
Example #4
0
    def test_delete_ziot_fail_not_concept(self):
        ziot = ZaakInformatieobjectTypeFactory.create(
            zaaktype__concept=False, informatieobjecttype__concept=False)
        ziot_url = reverse(ziot)

        response = self.client.delete(ziot_url)

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], "non-concept-relation")
Example #5
0
    def test_filter_ziot_status_alles(self):
        ZaakInformatieobjectTypeFactory.create(
            zaaktype__concept=True, informatieobjecttype__concept=True)
        ZaakInformatieobjectTypeFactory.create(
            zaaktype__concept=False, informatieobjecttype__concept=True)
        ZaakInformatieobjectTypeFactory.create(
            zaaktype__concept=True, informatieobjecttype__concept=False)
        ZaakInformatieobjectTypeFactory.create(
            zaaktype__concept=False, informatieobjecttype__concept=False)

        response = self.client.get(self.list_url, {'status': 'alles'})
        self.assertEqual(response.status_code, 200)

        data = response.json()['results']

        self.assertEqual(len(data), 4)
Example #6
0
    def test_partial_update_ziot_informatieobjecttype(self):
        zaaktype = ZaakTypeFactory.create()
        ziot = ZaakInformatieobjectTypeFactory.create(zaaktype=zaaktype)
        ziot_url = reverse(ziot)
        informatieobjecttype = InformatieObjectTypeFactory.create()
        informatieobjecttype_url = reverse(informatieobjecttype)

        response = self.client.patch(
            ziot_url, {"informatieobjecttype": informatieobjecttype_url})

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], "relations-incorrect-catalogus")
Example #7
0
    def test_partial_update_ziot(self):
        zaaktype = ZaakTypeFactory.create()
        informatieobjecttype = InformatieObjectTypeFactory.create(
            catalogus=zaaktype.catalogus)
        ziot = ZaakInformatieobjectTypeFactory.create(
            zaaktype=zaaktype, informatieobjecttype=informatieobjecttype)
        ziot_url = reverse(ziot)

        response = self.client.patch(ziot_url, {"volgnummer": 12})

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data["volgnummer"], 12)

        ziot.refresh_from_db()
        self.assertEqual(ziot.volgnummer, 12)
    def test_no_changes_gives_304(self):
        """
        Because no changes are made to the zaakinformatieobjecttype, a code 304 should be
        returned
        """
        zaakinformatieobjecttype = ZaakInformatieobjectTypeFactory.create(
            volgnummer=1)
        zaakinformatieobjecttype._etag = calculate_etag(
            zaakinformatieobjecttype)
        zaakinformatieobjecttype.save(update_fields=["_etag"])
        etag = zaakinformatieobjecttype._etag

        response = self.client.get(reverse(zaakinformatieobjecttype),
                                   HTTP_IF_NONE_MATCH=f'"{etag}"')
        self.assertEqual(response.status_code, status.HTTP_304_NOT_MODIFIED)
Example #9
0
    def test_partial_update_ziot_not_concept_zaaktype_and_informatieobjecttype_fails(
        self, ):
        zaaktype = ZaakTypeFactory.create(concept=False)
        zaaktype_url = reverse(zaaktype)
        informatieobjecttype = InformatieObjectTypeFactory.create(
            catalogus=zaaktype.catalogus, concept=False)
        informatieobjecttype_url = reverse(informatieobjecttype)
        ziot = ZaakInformatieobjectTypeFactory.create(
            zaaktype=zaaktype, informatieobjecttype=informatieobjecttype)
        ziot_url = reverse(ziot)

        response = self.client.patch(ziot_url, {"volgnummer": 12})

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], "non-concept-relation")
Example #10
0
    def test_filter_zaaktype(self):
        ztiot1, ztiot2 = ZaakInformatieobjectTypeFactory.create_batch(
            2, zaaktype__concept=False, informatieobjecttype__concept=False)
        url = f'http://testserver{reverse(ztiot1)}'
        zaaktype1_url = reverse(ztiot1.zaaktype)
        zaaktype2_url = reverse(ztiot2.zaaktype)
        zaaktype1_url = f'http://testserver{zaaktype1_url}'
        zaaktype2_url = f'http://testserver{zaaktype2_url}'

        response = self.client.get(self.list_url, {'zaaktype': zaaktype1_url})

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

        data = response.json()['results']

        self.assertEqual(data[0]['url'], url)
        self.assertEqual(data[0]['zaaktype'], zaaktype1_url)
        self.assertNotEqual(data[0]['zaaktype'], zaaktype2_url)
Example #11
0
    def test_create_ziot_fail_not_unique(self):
        ziot = ZaakInformatieobjectTypeFactory(volgnummer=1)
        informatieobjecttype = InformatieObjectTypeFactory.create(
            catalogus=ziot.zaaktype.catalogus)
        data = {
            "zaaktype": f"http://testserver.com{reverse(ziot.zaaktype)}",
            "informatieobjecttype":
            f"http://testserver.com{reverse(informatieobjecttype)}",
            "volgnummer": ziot.volgnummer,
            "richting": RichtingChoices.inkomend,
        }

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

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], "unique")
    def test_invalidate_etag_after_change(self):
        """
        Because changes are made to the zaakinformatieobjecttype, a code 200 should be
        returned
        """
        zaakinformatieobjecttype = ZaakInformatieobjectTypeFactory.create(
            volgnummer=1, with_etag=True)
        zaakinformatieobjecttype._etag = calculate_etag(
            zaakinformatieobjecttype)
        zaakinformatieobjecttype.save(update_fields=["_etag"])
        etag = zaakinformatieobjecttype._etag

        zaakinformatieobjecttype.volgnummer = 2
        zaakinformatieobjecttype.save()

        response = self.client.get(reverse(zaakinformatieobjecttype),
                                   HTTP_IF_NONE_MATCH=f'"{etag}"')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
Example #13
0
    def test_filter_zaaktype(self):
        ztiot1, ztiot2 = ZaakInformatieobjectTypeFactory.create_batch(
            2, zaaktype__concept=False, informatieobjecttype__concept=False)
        url = f"http://testserver.com{reverse(ztiot1)}"
        zaaktype1_url = reverse(ztiot1.zaaktype)
        zaaktype2_url = reverse(ztiot2.zaaktype)
        zaaktype1_url = f"http://testserver.com{zaaktype1_url}"
        zaaktype2_url = f"http://testserver.com{zaaktype2_url}"

        response = self.client.get(self.list_url, {"zaaktype": zaaktype1_url},
                                   HTTP_HOST="testserver.com")

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

        data = response.json()["results"]

        self.assertEqual(data[0]["url"], url)
        self.assertEqual(data[0]["zaaktype"], zaaktype1_url)
        self.assertNotEqual(data[0]["zaaktype"], zaaktype2_url)
Example #14
0
    def test_get_detail(self):
        ztiot = ZaakInformatieobjectTypeFactory.create()
        url = reverse(ztiot)
        zaaktype_url = reverse(ztiot.zaaktype)
        informatieobjecttype_url = reverse(ztiot.informatieobjecttype)

        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)

        expected = {
            "url": f"http://testserver{url}",
            "zaaktype": f"http://testserver{zaaktype_url}",
            "informatieobjecttype":
            f"http://testserver{informatieobjecttype_url}",
            "volgnummer": ztiot.volgnummer,
            "richting": ztiot.richting,
            "statustype": None,
        }
        self.assertEqual(response.json(), expected)
    def test_filter_zaaktype(self):
        ztiot1, ztiot2 = ZaakInformatieobjectTypeFactory.create_batch(2)
        url = f'http://testserver{reverse(ztiot1)}'
        zaaktype1_url = reverse(
            ztiot1.zaaktype,
            kwargs={'catalogus_uuid': ztiot1.zaaktype.catalogus.uuid})
        zaaktype2_url = reverse(
            ztiot2.zaaktype,
            kwargs={'catalogus_uuid': ztiot2.zaaktype.catalogus.uuid})

        zaaktype1_url = f'http://testserver{zaaktype1_url}'
        zaaktype2_url = f'http://testserver{zaaktype2_url}'

        response = self.client.get(self.list_url, {'zaaktype': zaaktype1_url})

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.json()[0]['url'], url)
        self.assertEqual(response.json()[0]['zaaktype'], zaaktype1_url)
        self.assertNotEqual(response.json()[0]['zaaktype'], zaaktype2_url)
Example #16
0
    def test_get_detail(self):
        ztiot = ZaakInformatieobjectTypeFactory.create()
        url = reverse(ztiot)
        zaaktype_url = reverse(ztiot.zaaktype)
        informatieobjecttype_url = reverse(ztiot.informatieobjecttype, )

        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)

        expected = {
            'url': f'http://testserver{url}',
            'zaaktype': f'http://testserver{zaaktype_url}',
            'informatieobjecttype':
            f'http://testserver{informatieobjecttype_url}',
            'volgnummer': ztiot.volgnummer,
            'richting': ztiot.richting,
            'statustype': None,
        }
        self.assertEqual(response.json(), expected)
Example #17
0
    def setUp(self):
        super().setUp()

        self.ziot = ZaakInformatieobjectTypeFactory.create(
            zaaktype__catalogus=self.catalogus,
            informatieobjecttype__catalogus=self.catalogus,
            informatieobjecttype__zaaktypen=None,
            volgnummer=1,
        )

        self.informatieobjecttype = self.ziot.informatieobjecttype
        self.zaaktype = self.ziot.zaaktype

        self.rstiotarc = ZaakInformatieobjectTypeArchiefregimeFactory.create(
            zaak_informatieobject_type=self.ziot,
            resultaattype__is_relevant_voor=self.zaaktype,
            resultaattype__bepaalt_afwijkend_archiefregime_van=None,
        )

        self.resultaattype = self.rstiotarc.resultaattype

        self.rstiotarc_list_url = reverse(
            "api:rstiotarc-list",
            kwargs={
                "version": self.API_VERSION,
                "catalogus_pk": self.catalogus.pk,
                "zaaktype_pk": self.zaaktype.pk,
            },
        )

        self.rstiotarc_detail_url = reverse(
            "api:rstiotarc-detail",
            kwargs={
                "version": self.API_VERSION,
                "catalogus_pk": self.catalogus.pk,
                "zaaktype_pk": self.zaaktype.pk,
                "pk": self.rstiotarc.pk,
            },
        )
Example #18
0
    def setUp(self):
        super().setUp()

        self.ziot = ZaakInformatieobjectTypeFactory.create(
            zaaktype__maakt_deel_uit_van=self.catalogus,
            informatie_object_type__maakt_deel_uit_van=self.catalogus,
            informatie_object_type__zaaktypes=None,
            volgnummer=1,
        )

        self.informatieobjecttype = self.ziot.informatie_object_type
        self.zaaktype = self.ziot.zaaktype

        self.rstiotarc = ZaakInformatieobjectTypeArchiefregimeFactory.create(
            zaak_informatieobject_type=self.ziot,
            resultaattype__is_relevant_voor=self.zaaktype,
            resultaattype__bepaalt_afwijkend_archiefregime_van=None,
        )

        self.resultaattype = self.rstiotarc.resultaattype

        self.rstiotarc_list_url = reverse('api:rstiotarc-list',
                                          kwargs={
                                              'version': self.API_VERSION,
                                              'catalogus_pk':
                                              self.catalogus.pk,
                                              'zaaktype_pk': self.zaaktype.pk
                                          })

        self.rstiotarc_detail_url = reverse('api:rstiotarc-detail',
                                            kwargs={
                                                'version': self.API_VERSION,
                                                'catalogus_pk':
                                                self.catalogus.pk,
                                                'zaaktype_pk':
                                                self.zaaktype.pk,
                                                'pk': self.rstiotarc.pk,
                                            })
Example #19
0
    def test_full_update_ziot_informatieobjecttype(self):
        zaaktype = ZaakTypeFactory.create()
        ziot = ZaakInformatieobjectTypeFactory.create(zaaktype=zaaktype)
        ziot_url = reverse(ziot)
        informatieobjecttype = InformatieObjectTypeFactory.create()
        informatieobjecttype_url = reverse(informatieobjecttype)
        zaaktype_url = reverse(ziot.zaaktype)

        response = self.client.put(
            ziot_url,
            {
                "zaaktype": f"http://testserver{zaaktype_url}",
                "informatieobjecttype": informatieobjecttype_url,
                "volgnummer": ziot.volgnummer,
                "richting": ziot.richting,
                "statustype": None,
            },
        )

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], "relations-incorrect-catalogus")
    def test_zaakinformatieobjecttype_head_cache_header(self):
        zaakinformatieobjecttype = ZaakInformatieobjectTypeFactory.create()

        self.assertHeadHasETag(reverse(zaakinformatieobjecttype))
    def test_zaakinformatieobjecttype_get_cache_header(self):
        zaakinformatieobjecttype = ZaakInformatieobjectTypeFactory.create()

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

        self.assertHasETag(response)