def test_create_with_objecttype_besluit(self): besluit = BesluitFactory.create() eio = EnkelvoudigInformatieObjectFactory.create() # relate the two BesluitInformatieObjectFactory.create(besluit=besluit, informatieobject=eio.canonical) # get OIO created via signals oio = ObjectInformatieObject.objects.get() besluit_url = reverse(besluit) eio_url = reverse(eio) oio_url = reverse("objectinformatieobject-detail", kwargs={"uuid": oio.uuid}) response = self.client.post( self.list_url, { "object": f"http://testserver{besluit_url}", "informatieobject": f"http://testserver{eio_url}", "objectType": "besluit", }, ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual( response.data, { "url": f"http://testserver{oio_url}", "object": f"http://testserver{besluit_url}", "informatieobject": f"http://testserver{eio_url}", "object_type": "besluit", }, )
def test_create_with_objecttype_other_fail(self): besluit = BesluitFactory.create() eio = EnkelvoudigInformatieObjectFactory.create() eio_path = reverse(eio) eio_url = f"http://testserver{eio_path}" # relate the two BesluitInformatieObjectFactory.create( besluit=besluit, informatieobject=eio.canonical ) besluit_url = reverse(besluit) response = self.client.post( self.list_url, { "object": f"http://testserver{besluit_url}", "informatieobject": eio_url, "objectType": "other", }, ) self.assertEqual( response.status_code, status.HTTP_400_BAD_REQUEST, response.data ) error = get_validation_errors(response, "objectType") self.assertEqual(error["code"], "invalid_choice")
def test_delete_document_fail_exising_relations_besluit(self): eio = EnkelvoudigInformatieObjectFactory.create() eio_uuid = eio.uuid eio_path = reverse(eio) eio_url = f"https://external.documenten.nl/{eio_path}" self.adapter.register_uri( "GET", eio_url, json=get_eio_response(eio_path), ) self.create_zaak_besluit_services() besluit = self.create_besluit() BesluitInformatieObjectFactory.create(informatieobject=eio_url, besluit=besluit) informatieobject_delete_url = get_operation_url( "enkelvoudiginformatieobject_delete", uuid=eio_uuid, ) response = self.client.delete(informatieobject_delete_url) self.assertEqual( response.status_code, status.HTTP_400_BAD_REQUEST, response.data ) error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(error["code"], "pending-relations")
def test_filter_besluit(self): eio_1 = EnkelvoudigInformatieObjectFactory.create() eio_detail_url = f"http://openzaak.nl{reverse(eio_1)}" self.adapter.register_uri("GET", eio_detail_url, json=serialise_eio(eio_1, eio_detail_url)) self.create_zaak_besluit_services() besluit1 = self.create_besluit() bio = BesluitInformatieObjectFactory.create( informatieobject=eio_detail_url, besluit=besluit1) besluit2 = self.create_besluit() BesluitInformatieObjectFactory.create( informatieobject=eio_detail_url, besluit=besluit2) # may not show up besluit_url = reverse(bio.besluit) response = self.client.get( self.list_url, {"object": f"http://openzaak.nl{besluit_url}"}, HTTP_HOST="openzaak.nl", ) self.assertEqual(response.status_code, 200) self.assertEqual(len(response.data), 1) self.assertEqual(response.data[0]["informatieobject"], eio_detail_url)
def test_read_with_objecttype_besluit(self): self.create_zaak_besluit_services() besluit = self.create_besluit() eio = EnkelvoudigInformatieObjectFactory.create() eio_path = reverse(eio) eio_url = f"http://testserver{eio_path}" # relate the two self.adapter.get(eio_url, json=serialise_eio(eio, eio_url)) BesluitInformatieObjectFactory.create(besluit=besluit, informatieobject=eio_url) # get OIO created via signals oio = ObjectInformatieObject.objects.get() oio_url = reverse("objectinformatieobject-detail", kwargs={"uuid": oio.uuid}) besluit_url = reverse(besluit) response = self.client.get(oio_url) expeceted_response_data = { "url": f"http://testserver{oio_url}", "object": make_absolute_uri(besluit_url), "informatieobject": eio_url, "object_type": "besluit", } self.assertEqual(response.status_code, status.HTTP_200_OK, response.data) self.assertEqual(response.data, expeceted_response_data)
def test_read_with_objecttype_besluit(self): besluit = BesluitFactory.create() eio = EnkelvoudigInformatieObjectFactory.create() eio_path = reverse(eio) eio_url = f"http://testserver{eio_path}" # relate the two BesluitInformatieObjectFactory.create( besluit=besluit, informatieobject=eio.canonical ) # get OIO created via signals oio = ObjectInformatieObject.objects.get() oio_url = reverse("objectinformatieobject-detail", kwargs={"uuid": oio.uuid}) besluit_url = reverse(besluit) response = self.client.get(oio_url) expeceted_response_data = { "url": f"http://testserver{oio_url}", "object": f"http://testserver{besluit_url}", "informatieobject": eio_url, "object_type": "besluit", } self.assertEqual(response.status_code, status.HTTP_200_OK, response.data) self.assertEqual(response.data, expeceted_response_data)
def test_create_with_objecttype_besluit(self): besluit = BesluitFactory.create() eio = EnkelvoudigInformatieObjectFactory.create() eio_path = reverse(eio) BesluitInformatieObjectFactory.create( besluit=besluit, informatieobject=eio.canonical ) # get OIO created via signals ObjectInformatieObject.objects.get() besluit_url = reverse(besluit) response = self.client.post( self.list_url, { "object": f"http://testserver{besluit_url}", "informatieobject": f"http://testserver{eio_path}", "objectType": "besluit", }, ) self.assertEqual( response.status_code, status.HTTP_400_BAD_REQUEST, response.data ) error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(error["code"], "unique")
def test_filter_eio(self): eio_1 = EnkelvoudigInformatieObjectFactory.create() eio_2 = EnkelvoudigInformatieObjectFactory.create() eio_detail_url = f"http://example.com{reverse(eio_1)}" self.adapter.register_uri("GET", eio_detail_url, json=serialise_eio(eio_1, eio_detail_url)) self.create_zaak_besluit_services() zaak = self.create_zaak() besluit = self.create_besluit() BesluitInformatieObjectFactory.create(informatieobject=eio_detail_url, besluit=besluit) ZaakInformatieObjectFactory.create( informatieobject=f"http://example.com{reverse(eio_2)}", zaak=zaak) # may not show up response = self.client.get( self.list_url, {"informatieobject": eio_detail_url}, ) self.assertEqual(response.status_code, 200) self.assertEqual(len(response.data), 1) self.assertEqual(response.data[0]["informatieobject"], eio_detail_url)
def test_destroy_oio_remote_still_present(self): BesluitInformatieObjectFactory.create() oio = ObjectInformatieObject.objects.get() url = reverse(oio) response = self.client.delete(url) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(error["code"], "inconsistent-relation")
def test_filter_besluit(self): bio = BesluitInformatieObjectFactory.create() BesluitInformatieObjectFactory.create() # may not show up bio_detail_url = reverse(bio.informatieobject.latest_version) besluit_url = reverse(bio.besluit) response = self.client.get( self.list_url, {"object": f"http://testserver{besluit_url}"}) self.assertEqual(response.status_code, 200) self.assertEqual(len(response.data), 1) self.assertEqual(response.data[0]["informatieobject"], f"http://testserver{bio_detail_url}")
def test_destroy_oio_remote_still_present(self): eio = EnkelvoudigInformatieObjectFactory.create() eio_path = reverse(eio) eio_url = f"http://testserver{eio_path}" # relate the two self.adapter.get(eio_url, json=serialise_eio(eio, eio_url)) BesluitInformatieObjectFactory.create(informatieobject=eio_url) oio = ObjectInformatieObject.objects.get() url = reverse(oio) response = self.client.delete(url) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(error["code"], "inconsistent-relation")
def test_bio_creates_oio(self): bio = BesluitInformatieObjectFactory.create() oio = ObjectInformatieObject.objects.get() self.assertEqual(oio.informatieobject, bio.informatieobject) self.assertEqual(oio.object, bio.besluit)
def test_filter_besluit(self): bio = BesluitInformatieObjectFactory.create() BesluitInformatieObjectFactory.create() # may not show up eio_detail_url = ( f"http://openzaak.nl{reverse(bio.informatieobject.latest_version)}" ) besluit_url = reverse(bio.besluit) response = self.client.get( self.list_url, {"object": f"http://openzaak.nl{besluit_url}"}, HTTP_HOST="openzaak.nl", ) self.assertEqual(response.status_code, 200) self.assertEqual(len(response.data), 1) self.assertEqual(response.data[0]["informatieobject"], eio_detail_url)
def test_delete_document_fail_exising_relations_besluit(self): informatieobject = EnkelvoudigInformatieObjectCanonicalFactory.create() BesluitInformatieObjectFactory.create( informatieobject=informatieobject) informatieobject_delete_url = get_operation_url( "enkelvoudiginformatieobject_delete", uuid=informatieobject.latest_version.uuid, ) response = self.client.delete(informatieobject_delete_url) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.data) error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(error["code"], "pending-relations")
def test_bio_delete_oio(self): bio = BesluitInformatieObjectFactory.create() self.assertEqual(ObjectInformatieObject.objects.count(), 1) bio.delete() self.assertEqual(ObjectInformatieObject.objects.count(), 0)
def test_bio_delete_oio(self): self.adapter.get(self.eio_url, json=self.eio_response) bio = BesluitInformatieObjectFactory.create( informatieobject=self.eio_url) self.assertEqual(ObjectInformatieObject.objects.count(), 1) bio.delete() self.assertEqual(ObjectInformatieObject.objects.count(), 0)
def test_delete_document_fail_exising_relations_besluit(self): eio = EnkelvoudigInformatieObjectFactory.create() eio_uuid = eio.uuid eio_url = eio.get_url() self.create_zaak_besluit_services() besluit = self.create_besluit() BesluitInformatieObjectFactory.create(informatieobject=eio_url, besluit=besluit) informatieobject_delete_url = get_operation_url( "enkelvoudiginformatieobject_delete", uuid=eio_uuid, ) response = self.client.delete(informatieobject_delete_url) self.assertEqual( response.status_code, status.HTTP_400_BAD_REQUEST, response.data ) error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(error["code"], "pending-relations")
def test_bio_creates_oio(self): self.adapter.get(self.eio_url, json=self.eio_response) bio = BesluitInformatieObjectFactory.create( informatieobject=self.eio_url) oio = ObjectInformatieObject.objects.get() self.assertEqual( oio.get_informatieobject_url(), bio.informatieobject._initial_data["url"], ) self.assertEqual(oio.object, bio.besluit)
def test_filter_eio(self): eio_1 = EnkelvoudigInformatieObjectFactory.create() eio_2 = EnkelvoudigInformatieObjectFactory.create() eio_detail_url = f"http://openzaak.nl{reverse(eio_1)}" self.adapter.register_uri("GET", eio_detail_url, json=serialise_eio(eio_1, eio_detail_url)) BesluitInformatieObjectFactory.create(informatieobject=eio_detail_url) ZaakInformatieObjectFactory.create( informatieobject=f"http://openzaak.nl{reverse(eio_2)}" ) # may not show up response = self.client.get( self.list_url, {"informatieobject": eio_detail_url}, HTTP_HOST="openzaak.nl", ) self.assertEqual(response.status_code, 200) self.assertEqual(len(response.data), 1) self.assertEqual(response.data[0]["informatieobject"], eio_detail_url)
def test_delete_no_url_mapping(self): io = EnkelvoudigInformatieObjectFactory.create() io_url = io.get_url() self.adapter.get(io_url, json=serialise_eio(io, io_url)) self.create_zaak_besluit_services() besluit = self.create_besluit() bio = BesluitInformatieObjectFactory.create(informatieobject=io_url, besluit=besluit) bio_url = reverse(bio) # Remove all available mappings UrlMapping.objects.all().delete() response = self.client.delete(bio_url) # Test response self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.data) self.assertEqual( response.data["detail"], "CMIS-adapter could not shrink one of the URL fields.", )