def test_filter_resultaattype_status_alles(self): ResultaatTypeFactory.create(zaaktype__concept=True) ResultaatTypeFactory.create(zaaktype__concept=False) resultaattype_list_url = reverse('resultaattype-list') response = self.client.get(resultaattype_list_url, {'status': 'alles'}) self.assertEqual(response.status_code, 200) data = response.json()['results'] self.assertEqual(len(data), 2)
def test_pagination_page_param(self): ResultaatTypeFactory.create_batch(2, zaaktype__concept=False) resultaattype_list_url = reverse('resultaattype-list') response = self.client.get(resultaattype_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'])
def test_get_list_default_definitief(self): resultaattype1 = ResultaatTypeFactory.create(zaaktype__concept=True) resultaattype2 = ResultaatTypeFactory.create(zaaktype__concept=False) resultaattype_list_url = reverse('resultaattype-list') resultaattype2_url = reverse('resultaattype-detail', kwargs={'uuid': resultaattype2.uuid}) response = self.client.get(resultaattype_list_url) self.assertEqual(response.status_code, 200) data = response.json()['results'] self.assertEqual(len(data), 1) self.assertEqual(data[0]['url'], f'http://testserver{resultaattype2_url}')
def test_conditional_get_stale(self): resultaattype = ResultaatTypeFactory.create(with_etag=True) response = self.client.get(reverse(resultaattype), HTTP_IF_NONE_MATCH=f'"not-an-md5"') self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_conditional_get_304(self): resultaattype = ResultaatTypeFactory.create(with_etag=True) response = self.client.get( reverse(resultaattype), HTTP_IF_NONE_MATCH=f'"{resultaattype._etag}"') self.assertEqual(response.status_code, status.HTTP_304_NOT_MODIFIED)
def test_get_detail(self): resultaattype = ResultaatTypeFactory.create() url = reverse(resultaattype) zaaktype_url = reverse('zaaktype-detail', kwargs={ 'uuid': resultaattype.zaaktype.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}', 'zaaktype': f'http://testserver{zaaktype_url}', 'omschrijving': resultaattype.omschrijving, 'resultaattypeomschrijving': resultaattype.resultaattypeomschrijving, 'omschrijvingGeneriek': resultaattype.omschrijving_generiek, 'selectielijstklasse': resultaattype.selectielijstklasse, 'toelichting': '', 'archiefnominatie': resultaattype.archiefnominatie, 'archiefactietermijn': 'P10Y', 'brondatumArchiefprocedure': { 'afleidingswijze': None, 'datumkenmerk': None, 'einddatumBekend': False, 'objecttype': None, 'registratie': None, 'procestermijn': None, } })
def setUp(self): super().setUp() self.resultaattype = ResultaatTypeFactory.create( resultaattypeomschrijving='Verleend', is_relevant_voor__maakt_deel_uit_van=self.catalogus, bepaalt_afwijkend_archiefregime_van=None, ) self.zaaktype = self.resultaattype.is_relevant_voor self.resultaattype_list_url = reverse('api:resultaattype-list', kwargs={ 'version': self.API_VERSION, 'catalogus_pk': self.catalogus.pk, 'zaaktype_pk': self.zaaktype.pk }) self.resultaattype_detail_url = reverse('api:resultaattype-detail', kwargs={ 'version': self.API_VERSION, 'catalogus_pk': self.catalogus.pk, 'zaaktype_pk': self.zaaktype.pk, 'pk': self.resultaattype.pk, })
def test_delete_resultaattype(self): resultaattype = ResultaatTypeFactory.create() resultaattype_url = reverse('resultaattype-detail', kwargs={'uuid': resultaattype.uuid}) response = self.client.delete(resultaattype_url) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) self.assertFalse(ResultaatType.objects.filter(id=resultaattype.id))
def test_delete_resultaattype_fail_not_concept_zaaktype(self): resultaattype = ResultaatTypeFactory.create(zaaktype__concept=False) resultaattype_url = reverse('resultaattype-detail', kwargs={'uuid': resultaattype.uuid}) response = self.client.delete(resultaattype_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 resultaattype, a code 304 should be returned """ resultaattype = ResultaatTypeFactory.create(omschrijving="bla") resultaattype._etag = calculate_etag(resultaattype) resultaattype.save(update_fields=["_etag"]) etag = resultaattype._etag response = self.client.get(reverse(resultaattype), HTTP_IF_NONE_MATCH=f'"{etag}"') self.assertEqual(response.status_code, status.HTTP_304_NOT_MODIFIED)
def test_resultaattypen_embedded_zaaktype(self): resultaattype = ResultaatTypeFactory.create() url = f'http://testserver{reverse(resultaattype)}' zaaktype_url = reverse('zaaktype-detail', kwargs={ 'uuid': resultaattype.zaaktype.uuid, }) response = self.client.get(zaaktype_url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual( response.json()['resultaattypen'], [url] )
def test_get_list(self): ResultaatTypeFactory.create_batch(3, zaaktype__concept=False) response = self.api_client.get(self.list_url) self.assertEqual(response.status_code, status.HTTP_200_OK) data = response.json()['results'] self.assertEqual(len(data), 3) self.assertResponseTypes( data[0], ( ('url', str), ('zaaktype', str), ('omschrijving', str), ('resultaattypeomschrijving', str), ('omschrijvingGeneriek', str), ('selectielijstklasse', str), ('toelichting', str), ('archiefnominatie', str), ('archiefactietermijn', str), ('brondatumArchiefprocedure', dict), ) )
def test_filter_on_zaaktype(self): zt1, zt2 = ZaakTypeFactory.create_batch(2, concept=False) rt1 = ResultaatTypeFactory.create(zaaktype=zt1) rt1_url = f'http://testserver{reverse(rt1)}' rt2 = ResultaatTypeFactory.create(zaaktype=zt2) rt2_url = f'http://testserver{reverse(rt2)}' zt1_url = 'http://testserver{}'.format(reverse('zaaktype-detail', kwargs={ 'uuid': zt1.uuid, })) zt2_url = 'http://testserver{}'.format(reverse('zaaktype-detail', kwargs={ 'uuid': zt2.uuid, })) list_url = reverse('resultaattype-list') response = self.client.get(list_url, {'zaaktype': zt1_url}) self.assertEqual(response.status_code, status.HTTP_200_OK) response_data = response.json()['results'] self.assertEqual(len(response_data), 1) self.assertEqual(response_data[0]['url'], rt1_url) self.assertEqual(response_data[0]['zaaktype'], zt1_url) self.assertNotEqual(response_data[0]['url'], rt2_url) self.assertNotEqual(response_data[0]['zaaktype'], zt2_url)
def test_invalidate_etag_after_change(self): """ Because changes are made to the resultaattype, a code 200 should be returned """ resultaattype = ResultaatTypeFactory.create(omschrijving="bla", with_etag=True) resultaattype._etag = calculate_etag(resultaattype) resultaattype.save(update_fields=["_etag"]) etag = resultaattype._etag resultaattype.omschrijving = "same" resultaattype.save() response = self.client.get(reverse(resultaattype), HTTP_IF_NONE_MATCH=f'"{etag}"') self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_resultaattype_afleidingswijze_procestermijn(self): resultaattype = ResultaatTypeFactory.create( brondatum_archiefprocedure_afleidingswijze='procestermijn', brondatum_archiefprocedure_procestermijn='P5Y', ) url = reverse(resultaattype) response = self.client.get(url) self.assertEqual(response.status_code, status.HTTP_200_OK) brondatumArchiefprocedure = response.json()['brondatumArchiefprocedure'] afleidingswijze = resultaattype.brondatum_archiefprocedure_afleidingswijze procestermijn = resultaattype.brondatum_archiefprocedure_procestermijn self.assertEqual(brondatumArchiefprocedure['afleidingswijze'], afleidingswijze) # Verify that the procestermijn was serialized correctly self.assertEqual(brondatumArchiefprocedure['procestermijn'], procestermijn)
def test_resultaattype_head_cache_header(self): resultaattype = ResultaatTypeFactory.create() self.assertHeadHasETag(reverse(resultaattype))
def test_resultaattype_get_cache_header(self): resultaattype = ResultaatTypeFactory.create() response = self.client.get(reverse(resultaattype)) self.assertHasETag(response)