Skip to content

Commit

Permalink
Merge pull request #1440 from open-zaak/feature/1439-documents-mutabl…
Browse files Browse the repository at this point in the history
…e-iotype

make eio.informatieobjecttype mutable
  • Loading branch information
annashamray committed Sep 11, 2023
2 parents 69c3789 + e61325b commit 2bc90c6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion bin/postman_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -x

POSTMAN_TESTS_REF=792d5d6a3c3548efac022275dcf4d5653db4a9b2
POSTMAN_TESTS_REF=c2cb87f164eba56701b776ade9ab8a8e7b5c65e2

# These client IDs and secrets are dummy variables that are only used by
# the Docker build in Travis, so they can be public
Expand Down
3 changes: 0 additions & 3 deletions src/openzaak/components/documenten/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from openzaak.utils.serializers import get_from_serializer_data_or_instance
from openzaak.utils.validators import (
IsImmutableValidator,
LooseFkIsImmutableValidator,
LooseFkResourceValidator,
PublishValidator,
)
Expand Down Expand Up @@ -296,7 +295,6 @@ class EnkelvoudigInformatieObjectSerializer(serializers.HyperlinkedModelSerializ
),
validators=[
LooseFkResourceValidator("InformatieObjectType", settings.ZTC_API_STANDARD),
LooseFkIsImmutableValidator(),
PublishValidator(),
],
)
Expand Down Expand Up @@ -362,7 +360,6 @@ class Meta:
LooseFkResourceValidator(
"InformatieObjectType", settings.ZTC_API_STANDARD
),
LooseFkIsImmutableValidator(),
PublishValidator(),
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,14 @@ class EnkelvoudigInformatieObjectVersionHistoryAPITests(JWTAuthMixin, APITestCas
heeft_alle_autorisaties = True

def test_eio_update(self):
iotype1, iotype2 = InformatieObjectTypeFactory.create_batch(2, concept=False)
eio = EnkelvoudigInformatieObjectFactory.create(
beschrijving="beschrijving1", informatieobjecttype__concept=False
beschrijving="beschrijving1", informatieobjecttype=iotype1
)

iotype2_url = reverse(
"informatieobjecttype-detail", kwargs={"uuid": iotype2.uuid}
)
eio_url = reverse(
"enkelvoudiginformatieobject-detail", kwargs={"uuid": eio.uuid}
)
Expand All @@ -534,6 +538,7 @@ def test_eio_update(self):
"inhoud": b64encode(b"aaaaa"),
"bestandsomvang": 5,
"lock": lock,
"informatieobjecttype": f"http://testserver{iotype2_url}",
}
)

Expand All @@ -556,10 +561,12 @@ def test_eio_update(self):
latest_version = eios.first()
self.assertEqual(latest_version.versie, 2)
self.assertEqual(latest_version.beschrijving, "beschrijving2")
self.assertEqual(latest_version.informatieobjecttype, iotype2)

first_version = eios[1]
self.assertEqual(first_version.versie, 1)
self.assertEqual(first_version.beschrijving, "beschrijving1")
self.assertEqual(first_version.informatieobjecttype, iotype1)

def test_eio_update_with_empty_content(self):
eio = EnkelvoudigInformatieObjectFactory.create(
Expand Down
18 changes: 8 additions & 10 deletions src/openzaak/components/documenten/tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from rest_framework.test import APITestCase
from vng_api_common.constants import ComponentTypes, VertrouwelijkheidsAanduiding
from vng_api_common.tests import get_validation_errors, reverse, reverse_lazy
from vng_api_common.validators import IsImmutableValidator
from zgw_consumers.constants import APITypes
from zgw_consumers.models import Service

Expand Down Expand Up @@ -145,23 +144,22 @@ def test_ondertekening_bad_values(self):

self.assertGegevensGroepValidation(url, "ondertekening", base_body, cases)

def test_update_informatieobjecttype_fails(self):
def test_update_informatieobjecttype_success(self):
"""changed in Documenten 1.3 - eio.informatieobject is now mutable"""
eio = EnkelvoudigInformatieObjectFactory.create()
eio_url = reverse(eio)

iotype = InformatieObjectTypeFactory.create()
iotype = InformatieObjectTypeFactory.create(concept=False)
iotype_url = reverse(iotype)
lock = self.client.post(f"{eio_url}/lock").data["lock"]

response = self.client.patch(
eio_url, {"informatieobjecttype": f"http://testserver{iotype_url}"}
eio_url,
{"informatieobjecttype": f"http://testserver{iotype_url}", "lock": lock},
)

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

error = get_validation_errors(response, "informatieobjecttype")
self.assertEqual(error["code"], IsImmutableValidator.code)
self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)
self.assertEqual(eio.canonical.latest_version.informatieobjecttype, iotype)

@temp_private_root()
def test_inhoud_incorrect_padding(self):
Expand Down

0 comments on commit 2bc90c6

Please sign in to comment.