Beispiel #1
0
    def test_unknown_query_params_give_error(self):
        StatusTypeFactory.create_batch(2)
        statustype_list_url = get_operation_url("statustype_list")

        response = self.client.get(statustype_list_url,
                                   {"someparam": "somevalue"})

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], "unknown-parameters")
Beispiel #2
0
    def test_filter_statustype_status_alles(self):
        StatusTypeFactory.create(zaaktype__concept=True)
        StatusTypeFactory.create(zaaktype__concept=False)
        statustype_list_url = reverse('statustype-list')

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

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

        self.assertEqual(len(data), 2)
Beispiel #3
0
    def test_pagination_default(self):
        StatusTypeFactory.create_batch(2, zaaktype__concept=False)
        statustype_list_url = reverse("statustype-list")

        response = self.client.get(statustype_list_url)

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

        response_data = response.json()
        self.assertEqual(response_data["count"], 2)
        self.assertIsNone(response_data["previous"])
        self.assertIsNone(response_data["next"])
Beispiel #4
0
    def test_pagination_page_param(self):
        StatusTypeFactory.create_batch(2, zaaktype__concept=False)
        statustype_list_url = reverse('statustype-list')

        response = self.client.get(statustype_list_url, {'page': 1})

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

        response_data = response.json()
        self.assertEqual(response_data['count'], 2)
        self.assertIsNone(response_data['previous'])
        self.assertIsNone(response_data['next'])
Beispiel #5
0
    def test_filter_statustype_status_concept(self):
        statustype1 = StatusTypeFactory.create(zaaktype__concept=True)
        statustype2 = StatusTypeFactory.create(zaaktype__concept=False)
        statustype_list_url = reverse('statustype-list')
        statustype1_url = reverse('statustype-detail',
                                  kwargs={'uuid': statustype1.uuid})

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

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

        self.assertEqual(len(data), 1)
        self.assertEqual(data[0]['url'], f'http://testserver{statustype1_url}')
Beispiel #6
0
    def test_filter_statustype_status_concept(self):
        statustype1 = StatusTypeFactory.create(zaaktype__concept=True)
        statustype2 = StatusTypeFactory.create(zaaktype__concept=False)
        statustype_list_url = reverse("statustype-list")
        statustype1_url = reverse("statustype-detail",
                                  kwargs={"uuid": statustype1.uuid})

        response = self.client.get(statustype_list_url, {"status": "concept"})
        self.assertEqual(response.status_code, 200)

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

        self.assertEqual(len(data), 1)
        self.assertEqual(data[0]["url"], f"http://testserver{statustype1_url}")
Beispiel #7
0
    def setUp(self):
        super().setUp()

        self.status_type = StatusTypeFactory.create(
            statustype_omschrijving='Besluit genomen',
            is_van__catalogus=self.catalogus,
        )

        self.zaaktype = self.status_type.is_van

        self.statustype_list_url = reverse('api:statustype-list',
                                           kwargs={
                                               'version': self.API_VERSION,
                                               'catalogus_pk':
                                               self.catalogus.pk,
                                               'zaaktype_pk': self.zaaktype.pk
                                           })
        self.statustype_detail_url = reverse('api:statustype-detail',
                                             kwargs={
                                                 'version': self.API_VERSION,
                                                 'catalogus_pk':
                                                 self.catalogus.pk,
                                                 'zaaktype_pk':
                                                 self.zaaktype.pk,
                                                 'pk': self.status_type.pk,
                                             })
Beispiel #8
0
    def test_get_detail(self):
        statustype = StatusTypeFactory.create(
            statustype_omschrijving="Besluit genomen",
            zaaktype__catalogus=self.catalogus,
        )
        statustype_detail_url = reverse("statustype-detail",
                                        kwargs={"uuid": statustype.uuid})
        zaaktype = statustype.zaaktype
        zaaktype_url = reverse("zaaktype-detail",
                               kwargs={"uuid": zaaktype.uuid})

        response = self.api_client.get(statustype_detail_url)

        self.assertEqual(response.status_code, 200)

        expected = {
            "url": "http://testserver{}".format(statustype_detail_url),
            "omschrijving": "Besluit genomen",
            "omschrijvingGeneriek": "",
            "statustekst": "",
            "zaaktype": "http://testserver{}".format(zaaktype_url),
            "volgnummer": statustype.statustypevolgnummer,
            "isEindstatus": True,
            "informeren": False,
        }

        self.assertEqual(expected, response.json())
    def test_conditional_get_stale(self):
        statustype = StatusTypeFactory.create(with_etag=True)

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

        self.assertEqual(response.status_code, status.HTTP_200_OK)
Beispiel #10
0
    def test_get_detail(self):
        statustype = StatusTypeFactory.create(
            statustype_omschrijving='Besluit genomen',
            zaaktype__catalogus=self.catalogus,
        )
        statustype_detail_url = reverse('statustype-detail',
                                        kwargs={
                                            'uuid': statustype.uuid,
                                        })
        zaaktype = statustype.zaaktype
        zaaktype_url = reverse('zaaktype-detail',
                               kwargs={
                                   'uuid': zaaktype.uuid,
                               })

        response = self.api_client.get(statustype_detail_url)

        self.assertEqual(response.status_code, 200)

        expected = {
            'url': 'http://testserver{}'.format(statustype_detail_url),
            'omschrijving': 'Besluit genomen',
            'omschrijvingGeneriek': '',
            'statustekst': '',
            'zaaktype': 'http://testserver{}'.format(zaaktype_url),
            'volgnummer': statustype.statustypevolgnummer,
            'isEindstatus': True,
            'informeren': False,
        }

        self.assertEqual(expected, response.json())
    def test_is_eindstatus(self):
        zaaktype = ZaakTypeFactory.create()

        rol_type = RolTypeFactory.create(zaaktype=zaaktype)

        statustype_1 = StatusTypeFactory.create(
            zaaktype=zaaktype,
            roltypen=[rol_type, ],
            statustypevolgnummer=1
        )
        statustype_2 = StatusTypeFactory.create(
            zaaktype=zaaktype,
            roltypen=[rol_type, ],
            statustypevolgnummer=2
        )

        # Volgnummer 1
        url = get_operation_url(
            'statustype_read',
            catalogus_uuid=zaaktype.catalogus.uuid,
            zaaktype_uuid=zaaktype.uuid,
            uuid=statustype_1.uuid,
        )

        response = self.client.get(url)

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

        self.assertFalse(response_data['isEindstatus'])

        # Volgnummer 2
        url = get_operation_url(
            'statustype_read',
            catalogus_uuid=zaaktype.catalogus.uuid,
            zaaktype_uuid=zaaktype.uuid,
            uuid=statustype_2.uuid
        )

        response = self.client.get(url)

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

        self.assertTrue(response_data['isEindstatus'])
Beispiel #12
0
    def test_delete_statustype(self):
        statustype = StatusTypeFactory.create()
        statustype_url = reverse('statustype-detail',
                                 kwargs={'uuid': statustype.uuid})

        response = self.client.delete(statustype_url)

        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
        self.assertFalse(StatusType.objects.filter(id=statustype.id))
Beispiel #13
0
    def test_delete_statustype_fail_not_concept_zaaktype(self):
        statustype = StatusTypeFactory.create(zaaktype__concept=False)
        statustype_url = reverse("statustype-detail",
                                 kwargs={"uuid": statustype.uuid})

        response = self.client.delete(statustype_url)

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], ZaakTypeConceptValidator.code)
Beispiel #14
0
    def test_delete_statustype_fail_not_concept_zaaktype(self):
        statustype = StatusTypeFactory.create(zaaktype__concept=False)
        statustype_url = reverse('statustype-detail',
                                 kwargs={'uuid': statustype.uuid})

        response = self.client.delete(statustype_url)

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

        data = response.json()
        self.assertEqual(data['detail'],
                         'Alleen concepten kunnen worden verwijderd.')
    def test_no_changes_gives_304(self):
        """
        Because no changes are made to the statustype, a code 304 should be
        returned
        """
        statustype = StatusTypeFactory.create(statustekst="bla")
        statustype._etag = calculate_etag(statustype)
        statustype.save(update_fields=["_etag"])
        etag = statustype._etag

        response = self.client.get(reverse(statustype),
                                   HTTP_IF_NONE_MATCH=f'"{etag}"')
        self.assertEqual(response.status_code, status.HTTP_304_NOT_MODIFIED)
Beispiel #16
0
    def test_partial_update_statustype_fail_not_concept_zaaktype(self):
        zaaktype = ZaakTypeFactory.create(concept=False)
        zaaktype_url = reverse(zaaktype)
        statustype = StatusTypeFactory.create(zaaktype=zaaktype)
        statustype_url = reverse(statustype)

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

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], ZaakTypeConceptValidator.code)
Beispiel #17
0
    def test_partial_update_statustype(self):
        zaaktype = ZaakTypeFactory.create()
        zaaktype_url = reverse(zaaktype)
        statustype = StatusTypeFactory.create(zaaktype=zaaktype)
        statustype_url = reverse(statustype)

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

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data["omschrijving"], "aangepast")

        statustype.refresh_from_db()
        self.assertEqual(statustype.statustype_omschrijving, "aangepast")
    def test_invalidate_etag_after_change(self):
        """
        Because changes are made to the statustype, a code 200 should be
        returned
        """
        statustype = StatusTypeFactory.create(statustekst="bla",
                                              with_etag=True)
        statustype._etag = calculate_etag(statustype)
        statustype.save(update_fields=["_etag"])
        etag = statustype._etag

        statustype.statustekst = "same"
        statustype.save()

        response = self.client.get(reverse(statustype),
                                   HTTP_IF_NONE_MATCH=f'"{etag}"')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
Beispiel #19
0
    def test_update_statustype_fail_not_concept_zaaktype(self):
        zaaktype = ZaakTypeFactory.create(concept=False)
        zaaktype_url = reverse(zaaktype)
        statustype = StatusTypeFactory.create(zaaktype=zaaktype)
        statustype_url = reverse(statustype)

        data = {
            "omschrijving": "aangepast",
            "omschrijvingGeneriek": "",
            "statustekst": "",
            "zaaktype": "http://testserver{}".format(zaaktype_url),
            "volgnummer": 2,
        }

        response = self.client.put(statustype_url, data)

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

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], ZaakTypeConceptValidator.code)
Beispiel #20
0
    def test_update_statustype(self):
        zaaktype = ZaakTypeFactory.create()
        zaaktype_url = reverse(zaaktype)
        statustype = StatusTypeFactory.create(zaaktype=zaaktype)
        statustype_url = reverse(statustype)

        data = {
            "omschrijving": "aangepast",
            "omschrijvingGeneriek": "",
            "statustekst": "",
            "zaaktype": "http://testserver{}".format(zaaktype_url),
            "volgnummer": 2,
        }

        response = self.client.put(statustype_url, data)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data["omschrijving"], "aangepast")

        statustype.refresh_from_db()
        self.assertEqual(statustype.statustype_omschrijving, "aangepast")
    def test_retrieve_statustype(self):
        statustype = StatusTypeFactory.create()
        url = get_operation_url(
            'statustype_read',
            catalogus_uuid=statustype.zaaktype.catalogus.uuid,
            zaaktype_uuid=statustype.zaaktype.uuid,
            uuid=statustype.uuid)

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        response_data = response.json()
        self.assertEqual(response_data['url'], f"http://testserver{url}")

        types = [
            ('omschrijving', str),
            ('omschrijvingGeneriek', str),
            ('statustekst', str),
            ('zaaktype', str),
        ]
        self.assertResponseTypes(response_data, types)
    def test_conditional_get_304(self):
        statustype = StatusTypeFactory.create(with_etag=True)
        response = self.client.get(reverse(statustype),
                                   HTTP_IF_NONE_MATCH=f'"{statustype._etag}"')

        self.assertEqual(response.status_code, status.HTTP_304_NOT_MODIFIED)
    def test_statustype_head_cache_header(self):
        statustype = StatusTypeFactory.create()

        self.assertHeadHasETag(reverse(statustype))
    def test_statustype_get_cache_header(self):
        statustype = StatusTypeFactory.create()

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

        self.assertHasETag(response)