def test_verblijfsobject(self): factories.AdresFactory() factories.AdresFactory() adres = factories.AdresFactory() adres.verblijfsobjecten = ['1111111111111111'] adres.save() url = reverse('bouwdossier-list') + '?verblijfsobject=1111111111111111' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 1) self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') delete_all_records()
def test_dossiernr_stadsdeel(self): factories.DocumentFactory(bouwdossier__dossiernr=111) factories.AdresFactory(bouwdossier__dossiernr=111 ) # Also add an address to the bouwdossier # And add two more dossiers to make sure it's only selecting the one we need factories.DocumentFactory(bouwdossier__dossiernr=222) factories.DocumentFactory(bouwdossier__dossiernr=333) url = reverse('bouwdossier-list') + '?dossiernr=111&stadsdeel=AA' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 1) self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') self.assertEqual( response.data['results'][0]['documenten'][0]['bestanden'][0] ['filename'], 'SU10000010_00001.jpg') self.assertEqual( response.data['results'][0]['documenten'][0]['bestanden'][0] ['url'], f"{settings.IIIF_BASE_URL}edepot:AA111-SU10000010_00001.jpg") self.assertEqual( response.data['results'][0]['documenten'][0]['access'], 'RESTRICTED') self.assertEqual( response.data['results'][0]['documenten'][0]['barcode'], 'ST100') self.assertEqual( response.data['results'][0]['adressen'][0]['nummeraanduidingen'] [0], '0363200000406187') self.assertEqual( response.data['results'][0]['adressen'][0]['panden'][0], '0363100012165490') delete_all_records()
def test_openbareruimte(self): factories.AdresFactory() factories.AdresFactory() adres = factories.AdresFactory() adres.openbareruimte_id = '1111111111111111' adres.save() url = reverse( 'bouwdossier-list' ) + '?verblijfsobject=036301000xxxxxxx/?openbareruimte=1111111111111111' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 1) self.assertEqual(response.data['results'][0]['titel'], 'weesperstraat 113 - 117') delete_all_records()
def test_nummeraanduiding_non_existent(self): factories.AdresFactory() url = reverse( 'bouwdossier-list') + '?nummeraanduiding=1111111111111111' response = self.client.get(url) self.assertIn('results', response.data) self.assertIn('count', response.data) self.assertEqual(response.data['count'], 0) delete_all_records()
def test_dossier_wabo_fields(self): bd = factories.BouwDossierFactory() factories.DocumentFactory(bouwdossier__dossiernr=bd.dossiernr) factories.AdresFactory(bouwdossier__dossiernr=bd.dossiernr ) # Also add an address to the bouwdossier dossier = BouwDossier.objects.get(stadsdeel='AA', dossiernr='12345') dossier.olo_liaan_nummer = '67890' dossier.wabo_bron = 'test' dossier.source = SOURCE_WABO dossier.save() document = dossier.documenten.first() document.bestanden = [ 'https://conversiestraatwabo.amsterdam.nl/webDAV/SDC/PUA/1234567.PDF' ] document.barcode = document.bestanden[0].split('/')[-1].split('.')[0] document.oorspronkelijk_pad = ['/path/to/bestand'] document.save() adres = dossier.adressen.first() adres.locatie_aanduiding = 'aanduiding' adres.huisnummer_letter = 'A' adres.huisnummer_toevoeging = 'B' adres.save() url = reverse('bouwdossier-detail', kwargs={'pk': 'AA12345'}) header = { 'HTTP_AUTHORIZATION': "Bearer " + create_authz_token(settings.BOUWDOSSIER_READ_SCOPE) } response = self.client.get(url, **header) documents = response.data.get('documenten') adressen = response.data['adressen'] self.assertEqual(response.data['olo_liaan_nummer'], 67890) self.assertEqual(response.data.get('wabo_bron'), None) # Bron is not needed in the api Check model self.assertEqual(documents[0]['oorspronkelijk_pad'], ['/path/to/bestand']) self.assertEqual( documents[0]['bestanden'][0]['url'], f"{settings.IIIF_BASE_URL}wabo:AA-12345-67890_1234567") self.assertEqual(adressen[0]['locatie_aanduiding'], 'aanduiding') self.assertEqual(adressen[0]['huisnummer_letter'], 'A') self.assertEqual(adressen[0]['huisnummer_toevoeging'], 'B') delete_all_records()