def test_besluittype_internal_iotype_external(self): besluit = BesluitFactory.create() besluit_url = f"http://openbesluit.nl{reverse(besluit)}" informatieobjecttype = f"{self.base}informatieobjecttypen/{uuid.uuid4()}" catalogus = f"{self.base}catalogussen/1c8e36be-338c-4c07-ac5e-1adf55bec04a" with requests_mock.Mocker(real_http=True) as m: m.get( informatieobjecttype, json=get_informatieobjecttype_response(catalogus, informatieobjecttype), ) m.get( catalogus, json=get_catalogus_response(catalogus, informatieobjecttype) ) m.get( self.document, json=get_eio_response( self.document, informatieobjecttype=informatieobjecttype ), ) response = self.client.post( self.list_url, {"besluit": besluit_url, "informatieobject": self.document}, HTTP_HOST="openbesluit.nl", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) error = get_validation_errors(response, "nonFieldErrors") self.assertEqual( error["code"], "missing-besluittype-informatieobjecttype-relation" )
def test_zaaktype_external_iotype_external_fail(self): catalogus = f"{self.base}catalogussen/1c8e36be-338c-4c07-ac5e-1adf55bec04a" zaaktype = f"{self.base}zaaktypen/b71f72ef-198d-44d8-af64-ae1932df830a" zaak = ZaakFactory.create(zaaktype=zaaktype) zaak_url = f"http://openzaak.nl{reverse(zaak)}" informatieobjecttype = f"{self.base}informatieobjecttypen/{uuid.uuid4()}" with requests_mock.Mocker(real_http=True) as m: m.get(zaaktype, json=get_zaaktype_response(catalogus, zaaktype)) m.get( informatieobjecttype, json=get_informatieobjecttype_response(catalogus, informatieobjecttype), ) m.get( self.document, json=get_eio_response( self.document, informatieobjecttype=informatieobjecttype), ) response = self.client.post( self.list_url, { "zaak": zaak_url, "informatieobject": self.document }, HTTP_HOST="openzaak.nl", ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) error = get_validation_errors(response, "nonFieldErrors") self.assertEqual(error["code"], "missing-zaaktype-informatieobjecttype-relation")
def test_besluittype_external_iotype_external_success(self): catalogus = f"{self.base}catalogussen/1c8e36be-338c-4c07-ac5e-1adf55bec04a" besluittype = f"{self.base}besluittypen/b71f72ef-198d-44d8-af64-ae1932df830a" besluit = BesluitFactory.create(besluittype=besluittype) besluit_url = f"http://openbesluit.nl{reverse(besluit)}" informatieobjecttype = f"{self.base}informatieobjecttypen/{uuid.uuid4()}" besluittype_data = get_besluittype_response(catalogus, besluittype) besluittype_data["informatieobjecttypen"] = [informatieobjecttype] with requests_mock.Mocker(real_http=True) as m: mock_service_oas_get(m, APITypes.drc, self.base) m.get(besluittype, json=besluittype_data) m.get( informatieobjecttype, json=get_informatieobjecttype_response(catalogus, informatieobjecttype), ) m.get( self.document, json=get_eio_response( self.document, informatieobjecttype=informatieobjecttype ), ) m.post( f"{self.base}objectinformatieobjecten", json=get_oio_response(self.document, besluit_url), status_code=201, ) response = self.client.post( self.list_url, {"besluit": besluit_url, "informatieobject": self.document}, HTTP_HOST="openbesluit.nl", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
def test_zaaktype_external_iotype_external_success(self): catalogus = f"{self.base}catalogussen/1c8e36be-338c-4c07-ac5e-1adf55bec04a" zaaktype = f"{self.base}zaaktypen/b71f72ef-198d-44d8-af64-ae1932df830a" zaak = ZaakFactory.create(zaaktype=zaaktype) zaak_url = f"http://openzaak.nl{reverse(zaak)}" informatieobjecttype = f"{self.base}informatieobjecttypen/{uuid.uuid4()}" zaaktype_data = get_zaaktype_response(catalogus, zaaktype) zaaktype_data["informatieobjecttypen"] = [informatieobjecttype] with requests_mock.Mocker(real_http=True) as m: m.get(zaaktype, json=zaaktype_data) m.get( informatieobjecttype, json=get_informatieobjecttype_response(catalogus, informatieobjecttype), ) m.get( self.document, json=get_eio_response( self.document, informatieobjecttype=informatieobjecttype ), ) m.post( f"{self.base}objectinformatieobjecten", json=get_oio_response(self.document, zaak_url), status_code=201, ) response = self.client.post( self.list_url, {"zaak": zaak_url, "informatieobject": self.document}, HTTP_HOST="openzaak.nl", ) self.assertEqual(response.status_code, status.HTTP_201_CREATED)