def test_changing_besluittype_informatieobjecttype_m2m_invalidates_both_etags(
            self):
        """
        Changing the M2M should modify both resources, resulting in 200 for
        when both resources are retrieved
        """
        besluittype = BesluitTypeFactory.create()
        besluittype._etag = calculate_etag(besluittype)
        besluittype.save(update_fields=["_etag"])
        besluittype_etag = besluittype._etag

        zaaktype = ZaakTypeFactory.create()
        zaaktype._etag = calculate_etag(zaaktype)
        zaaktype.save(update_fields=["_etag"])
        zaaktype_etag = zaaktype._etag

        besluittype.zaaktypen.set([zaaktype])
        besluittype.save()

        response = self.client.get(reverse(besluittype),
                                   HTTP_IF_NONE_MATCH=f'"{besluittype_etag}"')
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        response = self.client.get(reverse(zaaktype),
                                   HTTP_IF_NONE_MATCH=f'"{zaaktype_etag}"')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
    def test_conditional_get_stale(self):
        besluittype = BesluitTypeFactory.create(with_etag=True)

        response = self.client.get(reverse(besluittype),
                                   HTTP_IF_NONE_MATCH=f'"not-an-md5"')

        self.assertEqual(response.status_code, status.HTTP_200_OK)
    def test_no_changes_gives_304(self):
        """
        Because no changes are made to the besluittype, a code 304 should be
        returned
        """
        besluittype = BesluitTypeFactory.create(omschrijving="bla")
        besluittype._etag = calculate_etag(besluittype)
        besluittype.save(update_fields=["_etag"])
        etag = besluittype._etag

        response = self.client.get(reverse(besluittype),
                                   HTTP_IF_NONE_MATCH=f'"{etag}"')
        self.assertEqual(response.status_code, status.HTTP_304_NOT_MODIFIED)
    def test_invalidate_etag_after_change(self):
        """
        Because changes are made to the besluittype, a code 200 should be
        returned
        """
        besluittype = BesluitTypeFactory.create(omschrijving="bla",
                                                with_etag=True)
        besluittype._etag = calculate_etag(besluittype)
        besluittype.save(update_fields=["_etag"])
        etag = besluittype._etag

        besluittype.omschrijving = "same"
        besluittype.save()

        response = self.client.get(reverse(besluittype),
                                   HTTP_IF_NONE_MATCH=f'"{etag}"')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
    def test_conditional_get_304(self):
        besluittype = BesluitTypeFactory.create(with_etag=True)
        response = self.client.get(reverse(besluittype),
                                   HTTP_IF_NONE_MATCH=f'"{besluittype._etag}"')

        self.assertEqual(response.status_code, status.HTTP_304_NOT_MODIFIED)
    def test_besluittype_head_cache_header(self):
        besluittype = BesluitTypeFactory.create()

        self.assertHeadHasETag(reverse(besluittype))
    def test_besluittype_get_cache_header(self):
        besluittype = BesluitTypeFactory.create()

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

        self.assertHasETag(response)
Example #8
0
    def test_selectielijstprocestype_invalid_resource(self):
        besluittype = BesluitTypeFactory.create(catalogus=self.catalogus)
        besluittype_url = get_operation_url('besluittype_read',
                                            uuid=besluittype.uuid)

        responses = {
            'http://referentielijsten.nl/procestypen/1234': {
                'some': 'incorrect property'
            }
        }

        zaaktype_list_url = get_operation_url('zaaktype_list')
        data = {
            'identificatie':
            0,
            'doel':
            'some test',
            'aanleiding':
            'some test',
            'indicatieInternOfExtern':
            InternExtern.extern,
            'handelingInitiator':
            'indienen',
            'onderwerp':
            'Klacht',
            'handelingBehandelaar':
            'uitvoeren',
            'doorlooptijd':
            'P30D',
            'opschortingEnAanhoudingMogelijk':
            False,
            'verlengingMogelijk':
            True,
            'verlengingstermijn':
            'P30D',
            'publicatieIndicatie':
            True,
            'verantwoordingsrelatie': [],
            'productenOfDiensten': ['https://example.com/product/123'],
            'vertrouwelijkheidaanduiding':
            VertrouwelijkheidsAanduiding.openbaar,
            'omschrijving':
            'some test',
            'gerelateerdeZaaktypen': [
                {
                    'zaaktype': 'http://example.com/zaaktype/1',
                    'aard_relatie': AardRelatieChoices.bijdrage,
                    'toelichting': 'test relations'
                },
            ],
            'referentieproces': {
                'naam': 'ReferentieProces 0',
                'link': ''
            },
            'catalogus':
            f'http://testserver{self.catalogus_detail_url}',
            'besluittypen': [f'http://testserver{besluittype_url}'],
            'beginGeldigheid':
            '2018-01-01',
            'versiedatum':
            '2018-01-01',
            'selectielijstProcestype':
            'http://referentielijsten.nl/procestypen/1234'
        }

        with mock_client(responses):
            response = self.client.post(zaaktype_list_url, data)

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

        error = get_validation_errors(response, 'selectielijstProcestype')
        self.assertEqual(error['code'], 'invalid-resource')
Example #9
0
    def test_create_zaaktype_fail_besluittype_non_concept(self):
        besluittype = BesluitTypeFactory.create(concept=False,
                                                catalogus=self.catalogus)
        besluittype_url = get_operation_url('besluittype_read',
                                            uuid=besluittype.uuid)

        zaaktype_list_url = get_operation_url('zaaktype_list')
        data = {
            'identificatie':
            0,
            'doel':
            'some test',
            'aanleiding':
            'some test',
            'indicatieInternOfExtern':
            InternExtern.extern,
            'handelingInitiator':
            'indienen',
            'onderwerp':
            'Klacht',
            'handelingBehandelaar':
            'uitvoeren',
            'doorlooptijd':
            'P30D',
            'opschortingEnAanhoudingMogelijk':
            False,
            'verlengingMogelijk':
            True,
            'verlengingstermijn':
            'P30D',
            'publicatieIndicatie':
            True,
            'verantwoordingsrelatie': [],
            'productenOfDiensten': ['https://example.com/product/123'],
            'vertrouwelijkheidaanduiding':
            VertrouwelijkheidsAanduiding.openbaar,
            'omschrijving':
            'some test',
            'gerelateerdeZaaktypen': [
                {
                    'zaaktype': 'http://example.com/zaaktype/1',
                    'aard_relatie': AardRelatieChoices.bijdrage,
                    'toelichting': 'test relations'
                },
            ],
            'referentieproces': {
                'naam': 'ReferentieProces 0',
                'link': ''
            },
            'catalogus':
            f'http://testserver{self.catalogus_detail_url}',
            # 'informatieobjecttypen': [f'http://testserver{informatieobjecttype_url}'],
            'besluittypen': [f'http://testserver{besluittype_url}'],
            'beginGeldigheid':
            '2018-01-01',
            'versiedatum':
            '2018-01-01',
        }

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

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

        data = response.json()
        self.assertEqual(
            data['detail'],
            "Relations to a non-concept besluittype_set object can't be created"
        )