From 83bd1d002fd3d25caa215afbe984a6abe2fab020 Mon Sep 17 00:00:00 2001 From: damm89 Date: Wed, 7 Feb 2024 14:40:57 +0100 Subject: [PATCH] :white_check_mark: Fix tests after rebase on main --- .../test_command_add_atomic_permissions.py | 4 +- .../zac/camunda/tests/test_user_task_view.py | 15 +- .../contrib/objects/kownsl/api/serializers.py | 3 +- .../src/zac/contrib/objects/kownsl/data.py | 5 +- .../objects/kownsl/tests/test_camunda.py | 84 ++++++-- .../kownsl/tests/test_kownsl_services.py | 93 +++++--- .../kownsl/tests/test_review_request_views.py | 74 ++++--- .../test_zaak_review_request_reminder_view.py | 66 ++++-- .../tests/test_zaak_review_requests_views.py | 136 +++++++----- .../zac/contrib/objects/kownsl/tests/utils.py | 203 ++++++++++-------- .../tests/test_betrokkene_identificatie.py | 4 +- .../src/zac/core/tests/test_zet_resultaat.py | 33 ++- .../management/commands/index_objecten.py | 21 +- .../tests/test_api_documenten_search.py | 5 +- backend/src/zac/notifications/handlers.py | 8 +- .../tests/test_kownsl_review_updated.py | 38 ++-- backend/src/zac/werkvoorraad/serializers.py | 6 +- .../tests/test_review_requests_endpoint.py | 100 ++++++--- 18 files changed, 578 insertions(+), 320 deletions(-) diff --git a/backend/src/zac/accounts/tests/test_command_add_atomic_permissions.py b/backend/src/zac/accounts/tests/test_command_add_atomic_permissions.py index 364617e2d..90af9f5ab 100644 --- a/backend/src/zac/accounts/tests/test_command_add_atomic_permissions.py +++ b/backend/src/zac/accounts/tests/test_command_add_atomic_permissions.py @@ -9,7 +9,7 @@ from zgw_consumers.models import Service from zgw_consumers.test import generate_oas_component, mock_service_oas_get -from zac.contrib.objects.kownsl.tests.utils import REVIEW_REQUEST +from zac.contrib.objects.kownsl.tests.utils import ReviewRequestFactory from zac.contrib.objects.services import factory_review_request from zac.core.permissions import zaakproces_usertasks, zaken_inzien from zac.core.tests.utils import ClearCachesMixin @@ -162,7 +162,7 @@ def test_add_permission_for_advisor(self, m): vertrouwelijkheidaanduiding="zaakvertrouwelijk", eigenschappen=[], ) - review_request = deepcopy(REVIEW_REQUEST) + review_request = ReviewRequestFactory() review_request["zaak"] = zaak["url"] review_request["userDeadlines"] = {f"user:{self.user.username}": "2099-01-01"} diff --git a/backend/src/zac/camunda/tests/test_user_task_view.py b/backend/src/zac/camunda/tests/test_user_task_view.py index 3bca72d07..e71961fb9 100644 --- a/backend/src/zac/camunda/tests/test_user_task_view.py +++ b/backend/src/zac/camunda/tests/test_user_task_view.py @@ -28,7 +28,10 @@ from zac.camunda.data import Task from zac.contrib.dowc.data import OpenDowc from zac.contrib.objects.kownsl.constants import KownslTypes -from zac.contrib.objects.kownsl.tests.utils import REVIEW_REQUEST, REVIEWS_ADVICE +from zac.contrib.objects.kownsl.tests.utils import ( + ReviewRequestFactory, + ReviewsAdviceFactory, +) from zac.contrib.objects.services import factory_review_request, factory_reviews from zac.core.models import CoreConfig from zac.core.permissions import zaakproces_usertasks @@ -380,7 +383,7 @@ def test_get_reconfigure_advice_review_request_user_task(self, m, gt, ct): ) users = UserFactory.create_batch(3) - review_request_data = deepcopy(REVIEW_REQUEST) + review_request_data = ReviewRequestFactory() review_request_data["assignedUsers"] = [ { "deadline": "2020-01-01", @@ -570,8 +573,8 @@ def test_get_zet_resultaat_context(self, m, *mocks): json=paginated_response([self.zaaktype]), ) tasks = [_get_task(**{"formKey": "zac:zetResultaat"})] - review_request = factory_review_request(REVIEW_REQUEST) - reviews = factory_reviews(REVIEWS_ADVICE) + review_request = factory_review_request(ReviewRequestFactory()) + reviews = factory_reviews(ReviewsAdviceFactory()) mock_resource_get(m, self.zaaktype) resultaattype = generate_oas_component( "ztc", @@ -836,7 +839,7 @@ def test_put_configure_advice_review_request_user_task(self, m, gt, ct): "toelichting": "some-toelichting", "id": None, } - rr = deepcopy(REVIEW_REQUEST) + rr = ReviewRequestFactory() rr["assignedUsers"] = [ { "deadline": "2020-01-01", @@ -900,7 +903,7 @@ def test_put_configure_advice_review_request_user_task(self, m, gt, ct): def test_put_reconfigure_advice_review_request_user_task(self, m, gt, ct): self._mock_permissions(m) users = UserFactory.create_batch(3) - rr = deepcopy(REVIEW_REQUEST) + rr = ReviewRequestFactory() rr["assignedUsers"] = [ { "deadline": "2020-01-01", diff --git a/backend/src/zac/contrib/objects/kownsl/api/serializers.py b/backend/src/zac/contrib/objects/kownsl/api/serializers.py index 52afa70fe..8977534b9 100644 --- a/backend/src/zac/contrib/objects/kownsl/api/serializers.py +++ b/backend/src/zac/contrib/objects/kownsl/api/serializers.py @@ -355,9 +355,10 @@ class ZaakRevReqSummarySerializer(APIModelSerializer): can_lock = serializers.SerializerMethodField( label=_("can lock request"), help_text=_("User can lock the review request.") ) - completed = serializers.SerializerMethodField( + completed = serializers.IntegerField( label=_("completed requests"), help_text=_("The number of completed requests."), + source="get_completed", ) class Meta: diff --git a/backend/src/zac/contrib/objects/kownsl/data.py b/backend/src/zac/contrib/objects/kownsl/data.py index 7d9d1369a..ed55c7929 100644 --- a/backend/src/zac/contrib/objects/kownsl/data.py +++ b/backend/src/zac/contrib/objects/kownsl/data.py @@ -186,14 +186,17 @@ def get_open_reviews(self) -> List[OpenReview]: if not getattr(self, "open_reviews", []): user_deadlines = deepcopy(self.user_deadlines) + # remove those who have already reviewed for review in self.get_reviews(): + # if the reviewer is a group remove the group and... if name := review.group.get("name"): user_deadlines.pop(f"{AssigneeTypeChoices.group}:{name}", None) + # ... the user if the reviewer is a user author = f"{AssigneeTypeChoices.user}:{review.author['username']}" user_deadlines.pop(author, None) - # create dictionary of users for their information + # create dictionary of users for their information as stored on the review request object assignees = {} for assignee in self.assigned_users: for user in assignee.user_assignees: diff --git a/backend/src/zac/contrib/objects/kownsl/tests/test_camunda.py b/backend/src/zac/contrib/objects/kownsl/tests/test_camunda.py index 9bec1bc24..41a1937b1 100644 --- a/backend/src/zac/contrib/objects/kownsl/tests/test_camunda.py +++ b/backend/src/zac/contrib/objects/kownsl/tests/test_camunda.py @@ -1,7 +1,7 @@ -from copy import deepcopy from datetime import date from unittest.mock import MagicMock, patch +from django.contrib.sites.models import Site from django.urls import reverse import requests_mock @@ -11,11 +11,7 @@ from rest_framework.exceptions import ValidationError from rest_framework.test import APITestCase from zgw_consumers.api_models.base import factory -from zgw_consumers.api_models.catalogi import ( - InformatieObjectType, - ResultaatType, - ZaakType, -) +from zgw_consumers.api_models.catalogi import InformatieObjectType, ZaakType from zgw_consumers.api_models.constants import VertrouwelijkheidsAanduidingen from zgw_consumers.api_models.documenten import Document from zgw_consumers.constants import APITypes @@ -38,14 +34,16 @@ ZaakInformatieTaskSerializer, ) from .utils import ( - ADVICE, CATALOGI_ROOT, DOCUMENT_URL, DOCUMENTS_ROOT, - REVIEW_REQUEST, - REVIEWS_ADVICE, ZAAK_URL, ZAKEN_ROOT, + AdviceFactory, + AssignedUsersFactory, + ReviewRequestFactory, + ReviewsAdviceFactory, + UserAssigneeFactory, ) # Taken from https://docs.camunda.org/manual/7.13/reference/rest/task/get/ @@ -304,6 +302,25 @@ def test_approval_context_serializer_with_user(self, m): @requests_mock.Mocker() def test_advice_context_serializer_previously_assigned_users(self, m): + user_assignees = UserAssigneeFactory( + **{ + "username": "some-other-author", + "first_name": "Some Other First", + "last_name": "Some Last", + "full_name": "Some Other First Some Last", + } + ) + assigned_users2 = AssignedUsersFactory( + **{ + "deadline": "2022-04-15", + "user_assignees": [user_assignees], + "group_assignees": [], + "email_notification": False, + } + ) + review_request = ReviewRequestFactory() + review_request["assignedUsers"].append(assigned_users2) + task = _get_task(**{"formKey": "zac:configureAdviceRequest"}) m.get( f"https://camunda.example.com/engine-rest/task/{TASK_DATA['id']}/variables/assignedUsers?deserializeValue=false", @@ -311,20 +328,18 @@ def test_advice_context_serializer_previously_assigned_users(self, m): ) m.get( f"https://camunda.example.com/engine-rest/task/{TASK_DATA['id']}/variables/kownslReviewRequestId?deserializeValue=false", - json=serialize_variable(REVIEW_REQUEST["id"]), + json=serialize_variable(review_request["id"]), ) # Let resolve_assignee get the right users and groups UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][0]["userAssignees"][0] + username=review_request["assignedUsers"][0]["userAssignees"][0] ) UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][1]["userAssignees"][0] + username=review_request["assignedUsers"][1]["userAssignees"][0] ) - UserFactory.create(username="some-other-author") - - rr = factory(ReviewRequest, REVIEW_REQUEST) + rr = factory(ReviewRequest, review_request) rr.documents = [self.document.url] # Avoid patching fetch_reviews and everything @@ -354,7 +369,7 @@ def test_advice_context_serializer_previously_assigned_users(self, m): "identificatie": self.zaak.identificatie, }, ), - "id": REVIEW_REQUEST["id"], + "id": review_request["id"], "previously_assigned_users": [ { "user_assignees": [ @@ -406,6 +421,10 @@ def setUpTestData(cls): Service.objects.create(api_type=APITypes.zrc, api_root=ZAKEN_ROOT) Service.objects.create(api_type=APITypes.ztc, api_root=CATALOGI_ROOT) + site = Site.objects.get_current() + site.domain = "example" + site.save() + cls.catalogus = generate_oas_component( "ztc", "schemas/Catalogus", @@ -455,8 +474,26 @@ def setUpTestData(cls): "zac.core.api.validators.search_informatieobjects", return_value=[cls.document_es], ) - rr = deepcopy(REVIEW_REQUEST) + + user_assignees = UserAssigneeFactory( + **{ + "username": "some-other-author", + "first_name": "Some Other First", + "last_name": "Some Last", + "full_name": "Some Other First Some Last", + } + ) + assigned_users2 = AssignedUsersFactory( + **{ + "deadline": "2022-04-15", + "user_assignees": [user_assignees], + "group_assignees": [], + "email_notification": False, + } + ) + rr = ReviewRequestFactory() rr["documents"] = [cls.document.url] + rr["assignedUsers"].append(assigned_users2) # Let resolve_assignee get the right users and groups UserFactory.create(username=rr["assignedUsers"][0]["userAssignees"][0]) @@ -759,7 +796,7 @@ def test_configure_review_request_serializer_get_process_variables(self): [f"user:{user}" for user in self.users_1] + [f"group:{self.group}"] ], "kownslReviewRequestId": str(self.review_request.id), - "kownslFrontendUrl": f"http://example.com/ui/kownsl/review-request/advice?uuid={self.review_request.id}", + "kownslFrontendUrl": f"http://example/ui/kownsl/review-request/advice?uuid={self.review_request.id}", "emailNotificationList": email_notification_list, }, ) @@ -799,7 +836,10 @@ def test_configure_review_request_serializer_fail_get_process_variables(self): @freeze_time("1999-12-31T23:59:59Z") @requests_mock.Mocker() def test_reconfigure_review_request_serializer_user_already_reviewed(self, m): - user = UserFactory.create(username=ADVICE["author"]["username"]) + advice = AdviceFactory() + review_request = ReviewRequestFactory() + reviews_advice = ReviewsAdviceFactory() + user = UserFactory.create(username=advice["author"]["username"]) assigned_users = [ { "user_assignees": [user.username for user in self.users_1] @@ -819,15 +859,15 @@ def test_reconfigure_review_request_serializer_user_already_reviewed(self, m): "assigned_users": assigned_users, "toelichting": "some-toelichting", "documents": [self.document.url], - "id": REVIEW_REQUEST["id"], + "id": review_request["id"], } task = _get_task(**{"formKey": "zac:configureAdviceRequest"}) - rr = factory(ReviewRequest, REVIEW_REQUEST) + rr = factory(ReviewRequest, review_request) # Avoid patching fetch_reviews and everything - rr.reviews = factory(Reviews, REVIEWS_ADVICE).reviews + rr.reviews = factory(Reviews, reviews_advice).reviews rr.fetched_reviews = True with patch( diff --git a/backend/src/zac/contrib/objects/kownsl/tests/test_kownsl_services.py b/backend/src/zac/contrib/objects/kownsl/tests/test_kownsl_services.py index 70be999c7..516fe90ac 100644 --- a/backend/src/zac/contrib/objects/kownsl/tests/test_kownsl_services.py +++ b/backend/src/zac/contrib/objects/kownsl/tests/test_kownsl_services.py @@ -3,13 +3,11 @@ from django.test import TestCase -import jwt import requests_mock from django_camunda.utils import underscoreize from freezegun import freeze_time -from zds_client.auth import JWT_ALG from zgw_consumers.api_models.base import factory -from zgw_consumers.constants import APITypes, AuthTypes +from zgw_consumers.constants import APITypes from zgw_consumers.models import Service from zgw_consumers.test import generate_oas_component, mock_service_oas_get @@ -18,24 +16,20 @@ from zac.contrib.objects.kownsl.camunda import ConfigureReviewRequestSerializer from zac.contrib.objects.kownsl.constants import KownslTypes from zac.contrib.objects.kownsl.tests.utils import ( - ADVICE, - APPROVAL, - CATALOGI_ROOT, - DOCUMENT_URL, - DOCUMENTS_ROOT, OBJECTS_ROOT, OBJECTTYPES_ROOT, REVIEW_OBJECT, REVIEW_OBJECTTYPE, - REVIEW_OBJECTTYPE_LATEST_VERSION, - REVIEW_REQUEST, REVIEW_REQUEST_OBJECT, REVIEW_REQUEST_OBJECTTYPE, REVIEW_REQUEST_OBJECTTYPE_LATEST_VERSION, - REVIEWS_ADVICE, - ZAAK_DOCUMENT, ZAAK_URL, ZAKEN_ROOT, + AdviceFactory, + AssignedUsersFactory, + ReviewRequestFactory, + ReviewsAdviceFactory, + UserAssigneeFactory, ) from zac.core.models import CoreConfig, MetaObjectTypesConfig from zac.core.tests.utils import ClearCachesMixin @@ -62,13 +56,37 @@ def setUpTestData(cls): super().setUpTestData() zaak_json = generate_oas_component("zrc", "schemas/Zaak", url=ZAAK_URL) cls.zaak = factory(Zaak, zaak_json) + user_assignees = UserAssigneeFactory( + **{ + "username": "some-other-author", + "first_name": "Some Other First", + "last_name": "Some Last", + "full_name": "Some Other First Some Last", + } + ) + assigned_users2 = AssignedUsersFactory( + **{ + "deadline": "2022-04-15", + "user_assignees": [user_assignees], + "group_assignees": [], + "email_notification": False, + } + ) + cls.review_request = ReviewRequestFactory() + cls.review_request["assignedUsers"].append(assigned_users2) + cls.advice = AdviceFactory() + cls.reviews_advice = ReviewsAdviceFactory() + cls.reviews_advice["reviews"] = [cls.advice] + + cls.review_object = deepcopy(REVIEW_OBJECT) + cls.review_object["data"] = cls.reviews_advice # Make sure all users associated to the REVIEW REQUEST exist users = deepcopy( [ - REVIEW_REQUEST["assignedUsers"][0]["userAssignees"][0], - REVIEW_REQUEST["assignedUsers"][1]["userAssignees"][0], - REVIEW_REQUEST["requester"], + cls.review_request["assignedUsers"][0]["userAssignees"][0], + cls.review_request["assignedUsers"][1]["userAssignees"][0], + cls.review_request["requester"], ] ) # del full_name @@ -76,7 +94,9 @@ def setUpTestData(cls): del user["fullName"] UserFactory.create(**underscoreize(user)) - cls.user = User.objects.get(username=REVIEW_REQUEST["requester"]["username"]) + cls.user = User.objects.get( + username=cls.review_request["requester"]["username"] + ) Service.objects.create( label="Zaken API", api_type=APITypes.zrc, api_root=ZAKEN_ROOT ) @@ -106,8 +126,8 @@ def test_get_review_request(self, m): json=paginated_response([REVIEW_REQUEST_OBJECT]), ) - review_request = get_review_request(REVIEW_REQUEST["id"]) - self.assertEqual(str(review_request.id), REVIEW_REQUEST["id"]) + review_request = get_review_request(self.review_request["id"]) + self.assertEqual(str(review_request.id), self.review_request["id"]) def test_get_reviews(self, m): mock_service_oas_get(m, OBJECTS_ROOT, "objects") @@ -116,11 +136,13 @@ def test_get_reviews(self, m): m.get(f"{OBJECTTYPES_ROOT}objecttypes", json=[REVIEW_OBJECTTYPE]) m.post( f"{OBJECTS_ROOT}objects/search?pageSize=100", - json=paginated_response([REVIEW_OBJECT]), + json=paginated_response([self.review_object]), ) - reviews = fetch_reviews(review_request=REVIEW_REQUEST["id"]) - self.assertEqual(reviews[0]["record"]["data"], REVIEW_OBJECT["record"]["data"]) + reviews = fetch_reviews(review_request=self.review_request["id"]) + self.assertEqual( + reviews[0]["record"]["data"], self.review_object["record"]["data"] + ) @patch("zac.core.api.validators.validate_zaak_documents") def test_create_review_request_object_and_relate_to_zaak(self, m, *mocks): @@ -179,11 +201,11 @@ def test_create_review_request_object_and_relate_to_zaak(self, m, *mocks): m.post(f"{ZAKEN_ROOT}zaakobjecten", json=[], status_code=201) with patch( "zac.contrib.objects.services._create_unique_uuid_for_object", - return_value=REVIEW_REQUEST["id"], + return_value=self.review_request["id"], ): review_request = create_review_request(serializer.data) - self.assertEqual(str(review_request.id), REVIEW_REQUEST["id"]) + self.assertEqual(str(review_request.id), self.review_request["id"]) self.assertEqual(review_request.zaak, ZAAK_URL) self.assertEqual(review_request.is_being_reconfigured, False) self.assertEqual(review_request.lock_reason, "") @@ -209,7 +231,7 @@ def test_get_all_review_requests_for_zaak(self, m): review_requests = get_all_review_requests_for_zaak(self.zaak) request = review_requests[0] - self.assertEqual(str(request.id), REVIEW_REQUEST["id"]) + self.assertEqual(str(request.id), self.review_request["id"]) @patch("zac.core.api.validators.validate_zaak_documents") def test_update_assigned_users_review_request(self, m, *mocks): @@ -219,12 +241,12 @@ def test_update_assigned_users_review_request(self, m, *mocks): m.get(f"{OBJECTTYPES_ROOT}objecttypes", json=[REVIEW_REQUEST_OBJECTTYPE]) data = { - "id": REVIEW_REQUEST["id"], + "id": self.review_request["id"], "assigned_users": [ { "user_assignees": ["some-user"], "group_assignees": [], - "deadline": "2023-04-19", + "deadline": "2022-04-14", "email_notification": True, } ], @@ -235,7 +257,7 @@ def test_update_assigned_users_review_request(self, m, *mocks): request = MagicMock() request.user = User.objects.get( - username=REVIEW_REQUEST["requester"]["username"] + username=self.review_request["requester"]["username"] ) task = MagicMock() task.form_key = "zac:configureAdviceRequest" @@ -243,9 +265,10 @@ def test_update_assigned_users_review_request(self, m, *mocks): zaak_context = MagicMock() zaak_context.zaak = self.zaak - rr = factory_review_request(REVIEW_REQUEST) + rr = factory_review_request(self.review_request) # Avoid patching fetch_reviews and everything - rr.reviews = factory_reviews(REVIEWS_ADVICE).reviews + reviews_advice = ReviewsAdviceFactory() + rr.reviews = factory_reviews(reviews_advice).reviews rr.fetched_reviews = True with patch( "zac.contrib.objects.kownsl.camunda.get_zaak_context", @@ -273,10 +296,10 @@ def test_update_assigned_users_review_request(self, m, *mocks): return_value=REVIEW_REQUEST_OBJECT, ): review_request = update_review_request( - REVIEW_REQUEST["id"], requester=self.user, data=serializer.data + self.review_request["id"], requester=self.user, data=serializer.data ) - self.assertEqual(str(review_request.id), REVIEW_REQUEST["id"]) + self.assertEqual(str(review_request.id), self.review_request["id"]) self.assertEqual( m.last_request.json(), { @@ -298,7 +321,7 @@ def test_update_assigned_users_review_request(self, m, *mocks): ], "groupAssignees": [], "emailNotification": True, - "deadline": "2023-04-19", + "deadline": "2022-04-14", } ], "created": "2022-04-14 15:49:09.830235+00:00", @@ -318,7 +341,7 @@ def test_update_assigned_users_review_request(self, m, *mocks): }, "reviewType": "advice", "toelichting": "some-toelichting", - "userDeadlines": {"user:some-user": "2023-04-19"}, + "userDeadlines": {"user:some-user": "2022-04-14"}, "zaak": "https://zaken.nl/api/zaken/0c79c41d-72ef-4ea2-8c4c-03c9945da2a2", }, "geometry": "None", @@ -347,7 +370,7 @@ def test_lock_review_request(self, m): m.patch(REVIEW_REQUEST_OBJECT["url"], json=rr) review_request = lock_review_request( - REVIEW_REQUEST["id"], lock_reason="some-reason" + self.review_request["id"], lock_reason="some-reason" ) - self.assertEqual(str(review_request.id), REVIEW_REQUEST["id"]) + self.assertEqual(str(review_request.id), self.review_request["id"]) self.assertTrue(m.last_request.json()["record"]["data"]["locked"]) diff --git a/backend/src/zac/contrib/objects/kownsl/tests/test_review_request_views.py b/backend/src/zac/contrib/objects/kownsl/tests/test_review_request_views.py index fe26a2f37..69ecb8dc0 100644 --- a/backend/src/zac/contrib/objects/kownsl/tests/test_review_request_views.py +++ b/backend/src/zac/contrib/objects/kownsl/tests/test_review_request_views.py @@ -3,33 +3,27 @@ from django.urls import reverse -import jwt import requests_mock from furl import furl -from rest_framework import status from rest_framework.test import APITestCase -from zds_client.auth import JWT_ALG -from zgw_consumers.api_models.base import factory -from zgw_consumers.constants import APITypes, AuthTypes +from zgw_consumers.constants import APITypes from zgw_consumers.models import Service from zgw_consumers.test import generate_oas_component, mock_service_oas_get from zac.accounts.tests.factories import GroupFactory, UserFactory from zac.contrib.objects.services import factory_review_request, factory_reviews from zac.core.tests.utils import ClearCachesMixin -from zac.elasticsearch.documents import InformatieObjectDocument from zac.tests.utils import mock_resource_get -from zgw.models.zrc import Zaak from .utils import ( - ADVICE, DOCUMENTS_ROOT, - OBJECTS_ROOT, - OBJECTTYPES_ROOT, - REVIEW_REQUEST, - REVIEWS_ADVICE, ZAAK_URL, ZAKEN_ROOT, + AdviceFactory, + AssignedUsersFactory, + ReviewRequestFactory, + ReviewsAdviceFactory, + UserAssigneeFactory, ) @@ -52,14 +46,30 @@ def setUpTestData(cls): cls.user = UserFactory.create( username="some-user", first_name="John", last_name="Doe" ) - cls.group = GroupFactory.create(name="some-group") - UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][0]["userAssignees"][0] + cls.review_request = ReviewRequestFactory() + + user_assignees = UserAssigneeFactory( + **{ + "username": "some-other-author", + "first_name": "Some Other First", + "last_name": "Some Last", + "full_name": "Some Other First Some Last", + } ) - UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][1]["userAssignees"][0] + assigned_users2 = AssignedUsersFactory( + **{ + "deadline": "2022-04-15", + "user_assignees": [user_assignees], + "group_assignees": [], + "email_notification": False, + } ) + cls.review_request["assignedUsers"].append(assigned_users2) + cls.advice = AdviceFactory() + cls.reviews_advice = ReviewsAdviceFactory() + cls.group = GroupFactory.create(name="some-group") + def setUp(self): super().setUp() @@ -68,7 +78,7 @@ def test_fail_create_review_query_param(self, m): self.client.force_authenticate(user=self.user) url = reverse( "kownsl:reviewrequest-review", - kwargs={"request_uuid": REVIEW_REQUEST["id"]}, + kwargs={"request_uuid": self.review_request["id"]}, ) body = {"dummy": "data"} @@ -80,7 +90,7 @@ def test_fail_get_review_request_query_param(self, m): self.client.force_authenticate(user=self.user) url = reverse( "kownsl:reviewrequest-review", - kwargs={"request_uuid": REVIEW_REQUEST["id"]}, + kwargs={"request_uuid": self.review_request["id"]}, ) response = self.client.get(url) @@ -91,16 +101,16 @@ def test_success_get_review_request(self, m): mock_service_oas_get(m, ZAKEN_ROOT, "zrc") mock_resource_get(m, self.zaak) - rr = factory_review_request(REVIEW_REQUEST) + rr = factory_review_request(self.review_request) # Avoid patching fetch_reviews and everything rr.reviews = [] rr.fetched_reviews = True - user = UserFactory(username=ADVICE["author"]["username"]) + user = UserFactory(username=self.advice["author"]["username"]) self.client.force_authenticate(user=user) url = reverse( "kownsl:reviewrequest-review", - kwargs={"request_uuid": REVIEW_REQUEST["id"]}, + kwargs={"request_uuid": self.review_request["id"]}, ) url = furl(url).set({"assignee": f"user:{user}"}) @@ -114,16 +124,16 @@ def test_fail_get_review_already_exists(self, m): mock_service_oas_get(m, ZAKEN_ROOT, "zrc") mock_resource_get(m, self.zaak) - rr = factory_review_request(REVIEW_REQUEST) + rr = factory_review_request(self.review_request) # Avoid patching fetch_reviews and everything - rr.reviews = factory_reviews(REVIEWS_ADVICE).reviews + rr.reviews = factory_reviews(self.reviews_advice).reviews rr.fetched_reviews = True - user = UserFactory(username=ADVICE["author"]["username"]) + user = UserFactory(username=self.advice["author"]["username"]) self.client.force_authenticate(user=user) url = reverse( "kownsl:reviewrequest-review", - kwargs={"request_uuid": REVIEW_REQUEST["id"]}, + kwargs={"request_uuid": self.review_request["id"]}, ) url = furl(url).set({"assignee": f"user:{user}"}) @@ -143,9 +153,9 @@ def test_success_get_review_already_exists_for_group_but_not_user(self, m): mock_service_oas_get(m, ZAKEN_ROOT, "zrc") mock_resource_get(m, self.zaak) - rev_req = deepcopy(REVIEW_REQUEST) + rev_req = deepcopy(self.review_request) rev_req["userDeadlines"] = { - f"user:{ADVICE['author']['username']}": "2022-04-14", + f"user:{self.advice['author']['username']}": "2022-04-14", f"group:{self.group}": "2022-04-15", } rev_req["numAssignedUsers"] = 2 @@ -174,23 +184,23 @@ def test_success_get_review_already_exists_for_group_but_not_user(self, m): ] rr = factory_review_request(rev_req) - advice = deepcopy(ADVICE) + advice = deepcopy(self.advice) advice["adviceDocuments"] = list() advice["group"] = {"name": "some-other-group", "fullName": "groeop some group"} - reviews_advice = deepcopy(REVIEWS_ADVICE) + reviews_advice = deepcopy(self.reviews_advice) reviews_advice["reviews"] = [advice] # Avoid patching fetch_reviews and everything rr.reviews = factory_reviews(reviews_advice).reviews rr.fetched_reviews = True - user = UserFactory(username=ADVICE["author"]["username"]) + user = UserFactory(username=self.advice["author"]["username"]) user.groups.add(self.group) self.client.force_authenticate(user=user) url = reverse( "kownsl:reviewrequest-review", - kwargs={"request_uuid": REVIEW_REQUEST["id"]}, + kwargs={"request_uuid": self.review_request["id"]}, ) url = furl(url).set({"assignee": f"group:{self.group}"}) diff --git a/backend/src/zac/contrib/objects/kownsl/tests/test_zaak_review_request_reminder_view.py b/backend/src/zac/contrib/objects/kownsl/tests/test_zaak_review_request_reminder_view.py index 1909d7f21..3dd4e67c5 100644 --- a/backend/src/zac/contrib/objects/kownsl/tests/test_zaak_review_request_reminder_view.py +++ b/backend/src/zac/contrib/objects/kownsl/tests/test_zaak_review_request_reminder_view.py @@ -10,7 +10,7 @@ from zgw_consumers.api_models.base import factory from zgw_consumers.api_models.catalogi import ZaakType from zgw_consumers.api_models.constants import VertrouwelijkheidsAanduidingen -from zgw_consumers.constants import APITypes, AuthTypes +from zgw_consumers.constants import APITypes from zgw_consumers.models import Service from zgw_consumers.test import generate_oas_component, mock_service_oas_get @@ -26,7 +26,15 @@ from zac.tests.utils import mock_resource_get from zgw.models.zrc import Zaak -from .utils import CATALOGI_ROOT, DOCUMENTS_ROOT, REVIEW_REQUEST, ZAAK_URL, ZAKEN_ROOT +from .utils import ( + CATALOGI_ROOT, + DOCUMENTS_ROOT, + ZAAK_URL, + ZAKEN_ROOT, + AssignedUsersFactory, + ReviewRequestFactory, + UserAssigneeFactory, +) CAMUNDA_ROOT = "https://some.camunda.nl/" CAMUNDA_API_PATH = "engine-rest/" @@ -65,14 +73,34 @@ def setUpTestData(cls): cls.get_zaak_patcher = patch( "zac.contrib.objects.kownsl.api.views.get_zaak", return_value=zaak ) + + user_assignees = UserAssigneeFactory( + **{ + "username": "some-other-author", + "first_name": "Some Other First", + "last_name": "Some Last", + "full_name": "Some Other First Some Last", + } + ) + assigned_users2 = AssignedUsersFactory( + **{ + "deadline": "2022-04-15", + "user_assignees": [user_assignees], + "group_assignees": [], + "email_notification": False, + } + ) + cls.review_request = ReviewRequestFactory() + cls.review_request["assignedUsers"].append(assigned_users2) + # Let resolve_assignee get the right users and groups UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][0]["userAssignees"][0] + username=cls.review_request["assignedUsers"][0]["userAssignees"][0] ) UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][1]["userAssignees"][0] + username=cls.review_request["assignedUsers"][1]["userAssignees"][0] ) - review_request = factory(ReviewRequest, REVIEW_REQUEST) + review_request = factory(ReviewRequest, cls.review_request) cls.get_review_request_patcher = patch( "zac.contrib.objects.kownsl.api.views.get_review_request", return_value=review_request, @@ -103,7 +131,7 @@ def test_post_zaak_review_request_reminder(self, m): def test_get_zaak_review_request_is_locked(self, m): rr = factory( ReviewRequest, - {**REVIEW_REQUEST, "locked": True, "lockReason": "just a reason"}, + ReviewRequestFactory(locked=True, lock_reason="just a reason"), ) with patch( "zac.contrib.objects.kownsl.api.views.get_review_request", @@ -115,7 +143,7 @@ def test_get_zaak_review_request_is_locked(self, m): def test_get_zaak_review_request_not_found(self, m): rr = factory( ReviewRequest, - {**REVIEW_REQUEST, "locked": True, "lockReason": "just a reason"}, + ReviewRequestFactory(locked=True, lock_reason="just a reason"), ) with patch( "zac.contrib.objects.kownsl.api.views.get_review_request", @@ -172,14 +200,26 @@ def setUpTestData(cls): cls.get_zaak_patcher = patch( "zac.contrib.objects.kownsl.permissions.get_zaak", return_value=zaak ) - # Let resolve_assignee get the right users and groups - UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][0]["userAssignees"][0] + + user_assignees = UserAssigneeFactory( + **{ + "username": "some-other-author", + "first_name": "Some Other First", + "last_name": "Some Last", + "full_name": "Some Other First Some Last", + } ) - UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][1]["userAssignees"][0] + assigned_users2 = AssignedUsersFactory( + **{ + "deadline": "2022-04-15", + "user_assignees": [user_assignees], + "group_assignees": [], + "email_notification": False, + } ) - cls.review_request = factory(ReviewRequest, REVIEW_REQUEST) + cls.review_request = ReviewRequestFactory() + cls.review_request["assignedUsers"].append(assigned_users2) + cls.review_request = factory(ReviewRequest, cls.review_request) cls.patch_get_review_request = patch( "zac.contrib.objects.kownsl.api.views.get_review_request", return_value=cls.review_request, diff --git a/backend/src/zac/contrib/objects/kownsl/tests/test_zaak_review_requests_views.py b/backend/src/zac/contrib/objects/kownsl/tests/test_zaak_review_requests_views.py index 27aa27521..afdce2b87 100644 --- a/backend/src/zac/contrib/objects/kownsl/tests/test_zaak_review_requests_views.py +++ b/backend/src/zac/contrib/objects/kownsl/tests/test_zaak_review_requests_views.py @@ -30,14 +30,16 @@ from zgw.models.zrc import Zaak from .utils import ( - ADVICE, CATALOGI_ROOT, DOCUMENT_URL, DOCUMENTS_ROOT, - REVIEW_REQUEST, - REVIEWS_ADVICE, ZAAK_URL, ZAKEN_ROOT, + AdviceFactory, + AssignedUsersFactory, + ReviewRequestFactory, + ReviewsAdviceFactory, + UserAssigneeFactory, ) CATALOGUS_URL = f"{CATALOGI_ROOT}/catalogussen/e13e72de-56ba-42b6-be36-5c280e9b30cd" @@ -118,22 +120,34 @@ def setUpTestData(cls): return_value=[path.splitext(es_document.bestandsnaam)], ) - cls.revreq = { - **REVIEW_REQUEST, - "metadata": {"processInstanceId": "123"}, - "documents": [DOCUMENT_URL], - } - - # Let resolve_assignee get the right users and groups - UserFactory.create(username=cls.revreq["assignedUsers"][0]["userAssignees"][0]) - UserFactory.create(username=cls.revreq["assignedUsers"][1]["userAssignees"][0]) + user_assignees = UserAssigneeFactory( + **{ + "username": "some-other-author", + "first_name": "Some Other First", + "last_name": "Some Last", + "full_name": "Some Other First Some Last", + } + ) + assigned_users2 = AssignedUsersFactory( + **{ + "deadline": "2022-04-15", + "user_assignees": [user_assignees], + "group_assignees": [], + "email_notification": False, + } + ) + cls.review_request_dict = ReviewRequestFactory( + documents=[deepcopy(DOCUMENT_URL)] + ) + cls.review_request_dict["assignedUsers"].append(assigned_users2) - reviews = factory_reviews(REVIEWS_ADVICE) + cls.reviews = ReviewsAdviceFactory() + reviews = factory_reviews(cls.reviews) cls.get_reviews_patcher = patch( "zac.contrib.objects.services.get_reviews_for_review_request", return_value=reviews, ) - cls.review_request = factory(ReviewRequest, cls.revreq) + cls.review_request = factory(ReviewRequest, cls.review_request_dict) cls.get_review_request_patcher = patch( "zac.contrib.objects.kownsl.api.views.get_review_request", return_value=cls.review_request, @@ -176,7 +190,7 @@ def test_get_zaak_review_requests_completed(self, m): response_data, [ { - "id": REVIEW_REQUEST["id"], + "id": str(self.review_request.id), "reviewType": KownslTypes.advice, "completed": 0, "numAssignedUsers": 2, @@ -190,7 +204,7 @@ def test_get_zaak_review_requests_completed(self, m): def test_get_zaak_review_requests_can_lock(self, m): some_other_user = SuperUserFactory( - username=REVIEW_REQUEST["requester"]["username"] + username=self.review_request.requester["username"] ) self.client.force_authenticate(user=some_other_user) response = self.client.get(self.endpoint_summary) @@ -200,7 +214,7 @@ def test_get_zaak_review_requests_can_lock(self, m): response_data, [ { - "id": REVIEW_REQUEST["id"], + "id": str(self.review_request.id), "reviewType": KownslTypes.advice, "completed": 0, "numAssignedUsers": 2, @@ -213,10 +227,9 @@ def test_get_zaak_review_requests_can_lock(self, m): ) def test_get_zaak_review_requests_is_locked(self, m): - rr = factory( - ReviewRequest, - {**REVIEW_REQUEST, "locked": True, "lockReason": "just a reason"}, - ) + rr = deepcopy(self.review_request) + rr.locked = True + rr.lock_reason = "just a reason" with patch( "zac.contrib.objects.kownsl.api.views.get_all_review_requests_for_zaak", return_value=[rr], @@ -228,7 +241,7 @@ def test_get_zaak_review_requests_is_locked(self, m): response_data, [ { - "id": REVIEW_REQUEST["id"], + "id": str(rr.id), "reviewType": KownslTypes.advice, "completed": 0, "numAssignedUsers": 2, @@ -250,13 +263,12 @@ def test_get_zaak_review_requests_detail(self, m): self.assertEqual(response.status_code, status.HTTP_200_OK) response_data = response.json() - self.maxDiff = None self.assertEqual( response_data, { - "created": REVIEW_REQUEST["created"], + "created": self.review_request_dict["created"], "documents": [DOCUMENT_URL], - "id": REVIEW_REQUEST["id"], + "id": str(self.review_request.id), "isBeingReconfigured": False, "locked": False, "lockReason": "", @@ -273,7 +285,7 @@ def test_get_zaak_review_requests_detail(self, m): "lastName": "Some Last", "username": "some-author", }, - "reviewType": REVIEW_REQUEST["reviewType"], + "reviewType": self.review_request.review_type, "zaak": { "identificatie": self.zaak["identificatie"], "bronorganisatie": self.zaak["bronorganisatie"], @@ -296,6 +308,7 @@ def test_get_zaak_review_requests_detail(self, m): }, "lastEditedDate": None, "locked": self.document["locked"], + "lockedBy": "", "readUrl": "", "relatedZaken": [], "titel": self.document["titel"], @@ -309,7 +322,7 @@ def test_get_zaak_review_requests_detail(self, m): ], "advices": [ { - "advice": ADVICE["advice"], + "advice": self.reviews["reviews"][0]["advice"], "adviceDocuments": [ { "adviceUrl": "?versie=2", @@ -321,8 +334,8 @@ def test_get_zaak_review_requests_detail(self, m): "bestandsnaam": self.document["bestandsnaam"], } ], - "author": ADVICE["author"], - "created": ADVICE["created"], + "author": self.reviews["reviews"][0]["author"], + "created": self.reviews["reviews"][0]["created"], "group": {}, } ], @@ -353,11 +366,13 @@ def test_find_zaak_not_found(self, m): def test_update_review_request_lock(self, m): url = reverse( "kownsl:zaak-review-requests-detail", - kwargs={"request_uuid": REVIEW_REQUEST["id"]}, + kwargs={"request_uuid": self.review_request.id}, ) body = {"lock_reason": "some-reason"} - user = SuperUserFactory.create(username=REVIEW_REQUEST["requester"]["username"]) + user = SuperUserFactory.create( + username=self.review_request.requester["username"] + ) self.client.force_authenticate(user=user) rr = deepcopy(self.review_request) rr.locked = True @@ -382,11 +397,13 @@ def test_update_review_request_lock(self, m): def test_update_review_request_update_users(self, m, mock_send_message): url = reverse( "kownsl:zaak-review-requests-detail", - kwargs={"request_uuid": REVIEW_REQUEST["id"]}, + kwargs={"request_uuid": self.review_request.id}, ) body = {"update_users": True} - user = SuperUserFactory.create(username=REVIEW_REQUEST["requester"]["username"]) + user = SuperUserFactory.create( + username=self.review_request.requester["username"] + ) self.client.force_authenticate(user=user) with self.get_review_request_patcher: with self.get_reviews_patcher: @@ -404,7 +421,7 @@ def test_update_review_request_update_users(self, m, mock_send_message): self.assertEqual(response.status_code, status.HTTP_200_OK) mock_send_message.assert_called_once_with( - "change-process", [self.revreq["metadata"]["processInstanceId"]] + "change-process", [self.review_request.metadata["process_instance_id"]] ) patch_invalidate_cache.assert_called_once() patch_lock_review_request.assert_called_once() @@ -412,11 +429,13 @@ def test_update_review_request_update_users(self, m, mock_send_message): def test_update_review_request_lock_and_update_users_fail(self, m): url = reverse( "kownsl:zaak-review-requests-detail", - kwargs={"request_uuid": REVIEW_REQUEST["id"]}, + kwargs={"request_uuid": self.review_request.id}, ) body = {"lock_reason": "some-reason", "update_users": True} - user = SuperUserFactory.create(username=REVIEW_REQUEST["requester"]["username"]) + user = SuperUserFactory.create( + username=self.review_request.requester["username"] + ) self.client.force_authenticate(user=user) rr = deepcopy(self.review_request) rr.locked = True @@ -494,16 +513,27 @@ def setUpTestData(cls): "zac.contrib.objects.kownsl.permissions.get_zaak", return_value=zaak ) - # Let resolve_assignee get the right users and groups - UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][0]["userAssignees"][0] + user_assignees = UserAssigneeFactory( + **{ + "username": "some-other-author", + "first_name": "Some Other First", + "last_name": "Some Last", + "full_name": "Some Other First Some Last", + } ) - UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][1]["userAssignees"][0] + assigned_users2 = AssignedUsersFactory( + **{ + "deadline": "2022-04-15", + "user_assignees": [user_assignees], + "group_assignees": [], + "email_notification": False, + } ) + cls.review_request = ReviewRequestFactory(documents=[]) + cls.review_request["assignedUsers"].append(assigned_users2) + cls.review_request = factory(ReviewRequest, cls.review_request) + cls.advices = factory(Advice, [AdviceFactory()]) - cls.review_request = factory(ReviewRequest, REVIEW_REQUEST) - cls.advices = factory(Advice, [ADVICE]) document = factory(Document, cls.document) cls.endpoint_summary = reverse( "kownsl:zaak-review-requests-summary", @@ -515,7 +545,7 @@ def setUpTestData(cls): cls.endpoint_detail = reverse( "kownsl:zaak-review-requests-detail", kwargs={ - "request_uuid": REVIEW_REQUEST["id"], + "request_uuid": cls.review_request.id, }, ) @@ -708,7 +738,7 @@ def test_has_lock_perm(self, m): f"{CATALOGI_ROOT}zaaktypen?catalogus={self.zaaktype['catalogus']}", json=paginated_response([self.zaaktype]), ) - user = UserFactory.create(username=REVIEW_REQUEST["requester"]["username"]) + user = UserFactory.create(username=self.review_request.requester["username"]) # gives them access to the page, zaaktype and VA specified -> visible BlueprintPermissionFactory.create( role__permissions=[zaken_wijzigen.name], @@ -740,7 +770,7 @@ def test_review_request_is_locked(self, m): mock_service_oas_get(m, CATALOGI_ROOT, "ztc") mock_resource_get(m, self.catalogus) - user = UserFactory.create(username=REVIEW_REQUEST["requester"]["username"]) + user = UserFactory.create(username=self.review_request.requester["username"]) self.client.force_authenticate(user=user) BlueprintPermissionFactory.create( role__permissions=[zaken_wijzigen.name], @@ -753,7 +783,7 @@ def test_review_request_is_locked(self, m): ) with patch( "zac.contrib.objects.kownsl.api.views.get_review_request", - return_value=factory(ReviewRequest, {**REVIEW_REQUEST, "locked": True}), + return_value=factory(ReviewRequest, ReviewRequestFactory(locked=True)), ): response = self.client.patch(self.endpoint_detail, {"update_users": True}) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) @@ -767,7 +797,7 @@ def test_review_request_is_being_reconfigured(self, m): mock_service_oas_get(m, CATALOGI_ROOT, "ztc") mock_resource_get(m, self.catalogus) - user = UserFactory.create(username=REVIEW_REQUEST["requester"]["username"]) + user = UserFactory.create(username=self.review_request.requester["username"]) self.client.force_authenticate(user=user) BlueprintPermissionFactory.create( role__permissions=[zaken_wijzigen.name], @@ -782,7 +812,7 @@ def test_review_request_is_being_reconfigured(self, m): "zac.contrib.objects.kownsl.api.views.get_review_request", return_value=factory( ReviewRequest, - {**REVIEW_REQUEST, "is_being_reconfigured": True, "locked": False}, + ReviewRequestFactory(is_being_reconfigured=True, locked=False), ), ): response = self.client.patch(self.endpoint_detail, {"update_users": True}) @@ -807,7 +837,7 @@ def test_review_request_locked_get_regression(self, m): f"{CATALOGI_ROOT}zaaktypen?catalogus={self.zaaktype['catalogus']}", json=paginated_response([self.zaaktype]), ) - user = UserFactory.create(username=REVIEW_REQUEST["requester"]["username"]) + user = UserFactory.create(username=self.review_request.requester["username"]) # gives them access to the page, zaaktype and VA specified -> visible BlueprintPermissionFactory.create( role__permissions=[zaken_inzien.name], @@ -819,10 +849,12 @@ def test_review_request_locked_get_regression(self, m): }, ) self.client.force_authenticate(user=user) - rr = {**REVIEW_REQUEST, "locked": True, "lock_reason": "zomaar"} + rr = deepcopy(self.review_request) + rr.locked = True + rr.lock_reason = "zomaar" with patch( "zac.contrib.objects.kownsl.api.views.get_review_request", - return_value=factory(ReviewRequest, rr), + return_value=rr, ): response_detail = self.client.get(self.endpoint_detail) self.assertEqual(response_detail.status_code, status.HTTP_200_OK) diff --git a/backend/src/zac/contrib/objects/kownsl/tests/utils.py b/backend/src/zac/contrib/objects/kownsl/tests/utils.py index add5a04d8..9ab712274 100644 --- a/backend/src/zac/contrib/objects/kownsl/tests/utils.py +++ b/backend/src/zac/contrib/objects/kownsl/tests/utils.py @@ -1,3 +1,7 @@ +from copy import deepcopy + +import factory + from ..constants import KownslTypes ZAKEN_ROOT = "https://zaken.nl/" @@ -18,96 +22,121 @@ "title": "v2", } -REVIEW_REQUEST = { - "assignedUsers": [ - { - "deadline": "2022-04-14", - "userAssignees": [ - { - "username": "some-author", - "firstName": "Some First", - "lastName": "Some Last", - "fullName": "Some First Some Last", - } - ], - "groupAssignees": [], - "emailNotification": False, - }, + +class UserAssigneeFactory(factory.DictFactory): + username = "some-author" + first_name = "Some First" + last_name = "Some Last" + full_name = "Some First Some Last" + + class Meta: + rename = { + "first_name": "firstName", + "last_name": "lastName", + "full_name": "fullName", + } + + +class AssignedUsersFactory(factory.DictFactory): + deadline = "2022-04-14" + user_assignees = factory.List([factory.SubFactory(UserAssigneeFactory)]) + group_assignees = factory.List([]) + email_notification = False + + class Meta: + rename = { + "user_assignees": "userAssignees", + "email_notification": "emailNotification", + } + + +class MetaDataFactory(factory.DictFactory): + task_definition_id = "submitAdvice" + process_instance_id = "6ebf534a-bc0a-11ec-a591-c69dd6a420a0" + + class Meta: + rename = { + "task_definition_id": "taskDefinitionId", + "process_instance_id": "processInstanceId", + } + + +RR_ID = "14aec7a0-06de-4b55-b839-a1c9a0415b46" + + +class ReviewRequestFactory(factory.DictFactory): + assigned_users = factory.List([factory.SubFactory(AssignedUsersFactory)]) + created = "2022-04-14T15:49:09.830235Z" + documents = factory.List([]) + id = deepcopy(RR_ID) + is_being_reconfigured = False + locked = False + lockReason = "" + metadata = factory.SubFactory(MetaDataFactory) + num_reviews_given_before_change = 0 + requester = factory.SubFactory(UserAssigneeFactory) + review_type = KownslTypes.advice + toelichting = "some-toelichting" + user_deadlines = factory.Dict( { - "deadline": "2022-04-15", - "userAssignees": [ - { - "username": "some-other-author", - "firstName": "Some Other First", - "lastName": "Some Last", - "fullName": "Some Other First Some Last", - } - ], - "groupAssignees": [], - "emailNotification": False, - }, - ], - "created": "2022-04-14T15:49:09.830235Z", - "documents": list(), - "id": "14aec7a0-06de-4b55-b839-a1c9a0415b46", - "isBeingReconfigured": False, - "locked": False, - "lockReason": "", - "metadata": { - "taskDefinitionId": "submitAdvice", - "processInstanceId": "6ebf534a-bc0a-11ec-a591-c69dd6a420a0", - }, - "numReviewsGivenBeforeChange": 0, - "requester": { - "username": "some-author", - "firstName": "Some First", - "lastName": "Some Last", - "fullName": "Some First Some Last", - }, - "reviewType": KownslTypes.advice, - "toelichting": "some-toelichting", - "userDeadlines": { - "user:some-author": "2022-04-14", - "user:some-other-author": "2022-04-15", - }, - "zaak": ZAAK_URL, -} + "user:some-author": "2022-04-14", + "user:some-other-author": "2022-04-15", + } + ) + zaak = deepcopy(ZAAK_URL) -ADVICE = { - "created": "2022-04-14T15:50:09.830235Z", - "author": { - "username": "some-author", - "firstName": "Some First", - "lastName": "Some Last", - "fullName": "Some First Some Last", - }, - "advice": "some-advice", - "adviceDocuments": [ - {"document": DOCUMENT_URL, "sourceVersion": 1, "adviceVersion": 2} - ], -} + class Meta: + rename = { + "assigned_users": "assignedUsers", + "is_being_reconfigured": "isBeingReconfigured", + "num_reviews_given_before_change": "numReviewsGivenBeforeChange", + "review_type": "reviewType", + "user_deadlines": "userDeadlines", + } -APPROVAL = { - "created": "2022-04-14T15:51:09.830235Z", - "author": { - "username": "some-author", - "firstName": "Some First", - "lastName": "Some Last", - "fullName": "Some First Some Last", - }, - "approved": True, - "toelichting": "some-toelichting", -} +class AdviceDocumentFactory(factory.DictFactory): + document = deepcopy(DOCUMENT_URL) + source_version = 1 + advice_version = 2 + + class Meta: + rename = {"source_version": "sourceVersion", "advice_version": "adviceVersion"} + + +class AdviceFactory(factory.DictFactory): + created = "2022-04-14T15:50:09.830235Z" + author = factory.SubFactory(UserAssigneeFactory) + advice = "some-advice" + advice_documents = factory.List([factory.SubFactory(AdviceDocumentFactory)]) + + class Meta: + rename = { + "advice_documents": "adviceDocuments", + } + + +class ApprovalFactory(factory.DictFactory): + created = ("2022-04-14T15:51:09.830235Z",) + author = factory.SubFactory(UserAssigneeFactory) + approved = True + toelichting = "some-toelichting" + + +class ReviewsAdviceFactory(factory.DictFactory): + id = "6a9a169e-aa6f-4dd7-bbea-6bedea74c456" + meta = True + reviews = factory.List([factory.SubFactory(AdviceFactory)]) + review_request = deepcopy(RR_ID) + review_type = KownslTypes.advice + zaak = deepcopy(ZAAK_URL) + + class Meta: + rename = { + "review_request": "reviewRequest", + "review_type": "reviewType", + } -REVIEWS_ADVICE = { - "id": "6a9a169e-aa6f-4dd7-bbea-6bedea74c456", - "meta": True, - "reviews": [ADVICE], - "reviewRequest": REVIEW_REQUEST["id"], - "reviewType": "advice", - "zaak": ZAAK_URL, -} REVIEW_REQUEST_OBJECTTYPE = { "url": f"{OBJECTTYPES_ROOT}objecttypes/b4ec3f47-bc20-4872-955c-cb5f67646eae", @@ -252,7 +281,7 @@ "record": { "index": 1, "typeVersion": 4, - "data": REVIEW_REQUEST, + "data": ReviewRequestFactory(), "geometry": "None", "startAt": "1999-12-31", "endAt": "None", @@ -389,7 +418,7 @@ "record": { "index": 1, "typeVersion": 4, - "data": REVIEWS_ADVICE, + "data": {}, "geometry": "None", "startAt": "1999-12-31", "endAt": "None", diff --git a/backend/src/zac/core/api/tests/test_betrokkene_identificatie.py b/backend/src/zac/core/api/tests/test_betrokkene_identificatie.py index a28c466ba..5a1df4935 100644 --- a/backend/src/zac/core/api/tests/test_betrokkene_identificatie.py +++ b/backend/src/zac/core/api/tests/test_betrokkene_identificatie.py @@ -41,9 +41,7 @@ def test_user_does_not_exist(self): ) def test_user_exists(self): - user = UserFactory.create( - first_name="Some", last_name="User", username="some-user" - ) + UserFactory.create(first_name="Some", last_name="User", username="some-user") response = self.client.post(self.endpoint, self.payload, **self.headers) self.assertEqual( response.json(), diff --git a/backend/src/zac/core/tests/test_zet_resultaat.py b/backend/src/zac/core/tests/test_zet_resultaat.py index 424e99ad9..dea512e3e 100644 --- a/backend/src/zac/core/tests/test_zet_resultaat.py +++ b/backend/src/zac/core/tests/test_zet_resultaat.py @@ -12,14 +12,18 @@ from zgw_consumers.models import Service from zgw_consumers.test import generate_oas_component, mock_service_oas_get -from zac.accounts.tests.factories import UserFactory from zac.activities.constants import ActivityStatuses from zac.activities.tests.factories import ActivityFactory from zac.camunda.data import Task from zac.camunda.user_tasks import UserTaskData, get_context as _get_context from zac.contrib.dowc.models import DowcConfig from zac.contrib.objects.kownsl.data import ReviewRequest, Reviews -from zac.contrib.objects.kownsl.tests.utils import REVIEW_REQUEST, REVIEWS_ADVICE +from zac.contrib.objects.kownsl.tests.utils import ( + AssignedUsersFactory, + ReviewRequestFactory, + ReviewsAdviceFactory, + UserAssigneeFactory, +) from zac.tests.utils import mock_resource_get, paginated_response from ..camunda.zet_resultaat.serializers import ZetResultaatContextSerializer @@ -195,17 +199,28 @@ def test_zet_resultaat_context_serializer(self, m): checklist = deepcopy(CHECKLIST_OBJECT) checklist["record"]["data"]["answers"][0]["answer"] = "" - # Let resolve_assignee get the right users and groups - UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][0]["userAssignees"][0] + user_assignees = UserAssigneeFactory( + **{ + "username": "some-other-author", + "first_name": "Some Other First", + "last_name": "Some Last", + "full_name": "Some Other First Some Last", + } ) - UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][1]["userAssignees"][0] + assigned_users2 = AssignedUsersFactory( + **{ + "deadline": "2022-04-15", + "user_assignees": [user_assignees], + "group_assignees": [], + "email_notification": False, + } ) - rr = factory(ReviewRequest, REVIEW_REQUEST) + review_request = ReviewRequestFactory() + review_request["assignedUsers"].append(assigned_users2) + rr = factory(ReviewRequest, review_request) # Avoid patching fetch_reviews and everything - reviews = factory(Reviews, REVIEWS_ADVICE) + reviews = factory(Reviews, ReviewsAdviceFactory()) rr.fetched_reviews = True with patch( diff --git a/backend/src/zac/elasticsearch/management/commands/index_objecten.py b/backend/src/zac/elasticsearch/management/commands/index_objecten.py index a1bd5eae4..7ebd4d7d0 100644 --- a/backend/src/zac/elasticsearch/management/commands/index_objecten.py +++ b/backend/src/zac/elasticsearch/management/commands/index_objecten.py @@ -7,6 +7,7 @@ from elasticsearch_dsl.query import Term, Terms from zac.core.cache import invalidate_fetch_object_cache +from zac.core.models import MetaObjectTypesConfig from zac.core.services import ( fetch_objects, fetch_objects_all_paginated, @@ -26,7 +27,6 @@ ZaakDocument, ZaakObjectDocument, ) -from ...utils import check_if_index_exists from .base_index import IndexCommand perf_logger = logging.getLogger("performance") @@ -44,6 +44,14 @@ class Command(IndexCommand, BaseCommand): settings.ES_INDEX_ZO: ZaakObjectDocument, } + @property + def meta_config_urls(self) -> List[str]: + if not hasattr(self, "_meta_config_urls"): + self._meta_config_urls = list( + MetaObjectTypesConfig.get_solo().meta_objecttype_urls.values() + ) + return self._meta_config_urls + def batch_index(self) -> Iterator[ObjectDocument]: super().batch_index() self.stdout.write("Preloading all OBJECTTYPEn...") @@ -121,11 +129,12 @@ def documenten_generator(self, objects: List[Dict]) -> Iterator[ObjectDocument]: related_zaken = self.resolve_related_zaken(object_documenten) for obj in objects: - object_document = object_documenten[obj["url"]] - object_document.type = objecttype_documenten[obj["url"]] - object_document.related_zaken = related_zaken.get(obj["url"], []) - od = object_document.to_dict(True) - yield od + if obj["type"] not in self.meta_config_urls: + object_document = object_documenten[obj["url"]] + object_document.type = objecttype_documenten[obj["url"]] + object_document.related_zaken = related_zaken.get(obj["url"], []) + od = object_document.to_dict(True) + yield od def create_related_zaken( self, diff --git a/backend/src/zac/elasticsearch/tests/test_api_documenten_search.py b/backend/src/zac/elasticsearch/tests/test_api_documenten_search.py index 8b96d25ae..ad4c64278 100644 --- a/backend/src/zac/elasticsearch/tests/test_api_documenten_search.py +++ b/backend/src/zac/elasticsearch/tests/test_api_documenten_search.py @@ -248,7 +248,7 @@ class ESZaakDocumentsResponseTests(ClearCachesMixin, ESMixin, APITransactionTest titel="a", vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduidingen.openbaar, bestandsnaam="some-bestandsnaam1.ext1", - locked=True + locked=True, ), ) document1.informatieobjecttype = iot @@ -263,6 +263,7 @@ class ESZaakDocumentsResponseTests(ClearCachesMixin, ESMixin, APITransactionTest titel="b", vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduidingen.openbaar, bestandsnaam="some-bestandsnaam2.ext2", + locked=False, ), ) document2.informatieobjecttype = iot @@ -472,7 +473,7 @@ def test_response(self, m): }, "lastEditedDate": None, "locked": self.document1.locked, - "lockedBy": user.email, + "lockedBy": user.email if self.document1.locked else "", "readUrl": f"/api/dowc/{self.document1.bronorganisatie}/{self.document1.identificatie}/read", "relatedZaken": [], "titel": self.document1.titel, diff --git a/backend/src/zac/notifications/handlers.py b/backend/src/zac/notifications/handlers.py index 3072dd6d8..fb311ddcc 100644 --- a/backend/src/zac/notifications/handlers.py +++ b/backend/src/zac/notifications/handlers.py @@ -358,7 +358,13 @@ def handle(self, data: dict) -> None: meta_object_handler = self._meta_object_handler() if func := meta_object_handler.get(object["type"]["url"], None): func(object) - update_object_document(object) + + # Don't index meta objects. + if ( + object["type"]["url"] + not in MetaObjectTypesConfig.get_solo().meta_objecttype_urls.values() + ): + update_object_document(object) elif data["actie"] == "destroy": delete_object_document(data["hoofd_object"]) diff --git a/backend/src/zac/notifications/tests/test_kownsl_review_updated.py b/backend/src/zac/notifications/tests/test_kownsl_review_updated.py index 6c610d54e..d521018d9 100644 --- a/backend/src/zac/notifications/tests/test_kownsl_review_updated.py +++ b/backend/src/zac/notifications/tests/test_kownsl_review_updated.py @@ -15,10 +15,10 @@ from zac.accounts.tests.factories import UserFactory from zac.contrib.objects.kownsl.data import ReviewRequest from zac.contrib.objects.kownsl.tests.utils import ( - REVIEW_REQUEST, REVIEW_REQUEST_OBJECT, REVIEW_REQUEST_OBJECTTYPE, ZAKEN_ROOT, + ReviewRequestFactory, ) from zac.core.models import MetaObjectTypesConfig from zac.core.tests.utils import ClearCachesMixin @@ -47,7 +47,7 @@ "parentTaskId": None, "priority": 42, "processDefinitionId": "aProcDefId", - "processInstanceId": REVIEW_REQUEST["metadata"]["processInstanceId"], + "processInstanceId": "", "caseDefinitionId": "aCaseDefId", "caseInstanceId": "aCaseInstId", "caseExecutionId": "aCaseExecution", @@ -81,6 +81,11 @@ def setUpTestData(cls): confg = MetaObjectTypesConfig.get_solo() confg.review_request_objecttype = REVIEW_REQUEST_OBJECTTYPE["url"] confg.save() + cls.review_request = ReviewRequestFactory() + cls.task_data = deepcopy(TASK_DATA) + cls.task_data["processInstanceId"] = cls.review_request["metadata"][ + "processInstanceId" + ] def setUp(self): super().setUp() @@ -95,14 +100,14 @@ def setUp(self): def test_user_task_send_message_locked(self, m, mock_invalidate_cache): mock_resource_get(m, REVIEW_REQUEST_OBJECT) m.get( - f"https://camunda.example.com/engine-rest/task?processInstanceId={REVIEW_REQUEST['metadata']['processInstanceId']}&taskDefinitionKey={REVIEW_REQUEST['metadata']['taskDefinitionId']}&assignee=user%3Abob", - json=[{**TASK_DATA, "assignee": f"user:bob"}], + f"https://camunda.example.com/engine-rest/task?processInstanceId={self.review_request['metadata']['processInstanceId']}&taskDefinitionKey={self.review_request['metadata']['taskDefinitionId']}&assignee=user%3Abob", + json=[{**self.task_data, "assignee": f"user:bob"}], ) m.post( "https://camunda.example.com/engine-rest/message", ) - rr = factory(ReviewRequest, REVIEW_REQUEST) + rr = factory(ReviewRequest, self.review_request) rr.locked = True with patch("zac.notifications.handlers.get_review_request", return_value=rr): response = self.client.post(self.endpoint, NOTIFICATION) @@ -117,26 +122,29 @@ def test_user_task_send_message_locked(self, m, mock_invalidate_cache): def test_review_request_updated_clears_cache(self, m): Service.objects.create(api_type=APITypes.zrc, api_root=ZAKEN_ROOT) - zaak = generate_oas_component("zrc", "schemas/Zaak", url=REVIEW_REQUEST["zaak"]) + zaak = generate_oas_component( + "zrc", "schemas/Zaak", url=self.review_request["zaak"] + ) mock_resource_get(m, REVIEW_REQUEST_OBJECT) m.get( - f"https://camunda.example.com/engine-rest/task?processInstanceId={REVIEW_REQUEST['metadata']['processInstanceId']}&taskDefinitionKey={REVIEW_REQUEST['metadata']['taskDefinitionId']}&assignee=user%3Abob", - json=[{**TASK_DATA, "assignee": f"user:bob"}], + f"https://camunda.example.com/engine-rest/task?processInstanceId={self.review_request['metadata']['processInstanceId']}&taskDefinitionKey={self.review_request['metadata']['taskDefinitionId']}&assignee=user%3Abob", + json=[{**self.task_data, "assignee": f"user:bob"}], ) m.post( "https://camunda.example.com/engine-rest/message", ) - # create users - UserFactory.create(username="some-author") - UserFactory.create(username="some-other-author") # Fill cache - cache.set(f"review_request:detail:{REVIEW_REQUEST['id']}", "hello") - self.assertTrue(cache.has_key(f"review_request:detail:{REVIEW_REQUEST['id']}")) + cache.set(f"review_request:detail:{self.review_request['id']}", "hello") + self.assertTrue( + cache.has_key(f"review_request:detail:{self.review_request['id']}") + ) - rr = factory(ReviewRequest, REVIEW_REQUEST) + rr = factory(ReviewRequest, self.review_request) with patch("zac.notifications.handlers.get_review_request", return_value=rr): response = self.client.post(self.endpoint, NOTIFICATION) self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) - self.assertFalse(cache.has_key(f"review_request:detail:{REVIEW_REQUEST['id']}")) + self.assertFalse( + cache.has_key(f"review_request:detail:{self.review_request['id']}") + ) diff --git a/backend/src/zac/werkvoorraad/serializers.py b/backend/src/zac/werkvoorraad/serializers.py index 6e7dcee83..da33e94bb 100644 --- a/backend/src/zac/werkvoorraad/serializers.py +++ b/backend/src/zac/werkvoorraad/serializers.py @@ -186,8 +186,10 @@ class WorkStackReviewRequestSerializer(PolymorphicSerializer): ), required=True, ) - completed = serializers.SerializerMethodField( - label=_("completed requests"), help_text=_("The number of completed requests.") + completed = serializers.IntegerField( + label=_("completed requests"), + help_text=_("The number of completed requests."), + source="get_completed", ) zaak = SummaryZaakDocumentSerializer( help_text=_("ZAAK that review request belongs to.") diff --git a/backend/src/zac/werkvoorraad/tests/test_review_requests_endpoint.py b/backend/src/zac/werkvoorraad/tests/test_review_requests_endpoint.py index 0ba23d2f8..1d8c9f626 100644 --- a/backend/src/zac/werkvoorraad/tests/test_review_requests_endpoint.py +++ b/backend/src/zac/werkvoorraad/tests/test_review_requests_endpoint.py @@ -1,3 +1,4 @@ +from copy import deepcopy from unittest.mock import patch from django.urls import reverse @@ -8,19 +9,22 @@ from zgw_consumers.models import Service from zgw_consumers.test import generate_oas_component, mock_service_oas_get -from zac.accounts.tests.factories import GroupFactory, UserFactory +from zac.accounts.tests.factories import UserFactory from zac.contrib.objects.kownsl.tests.utils import ( - ADVICE, CATALOGI_ROOT, OBJECTS_ROOT, OBJECTTYPES_ROOT, REVIEW_OBJECT, REVIEW_OBJECTTYPE, - REVIEW_REQUEST, REVIEW_REQUEST_OBJECT, REVIEW_REQUEST_OBJECTTYPE, ZAAK_URL, ZAKEN_ROOT, + AdviceFactory, + AssignedUsersFactory, + ReviewRequestFactory, + ReviewsAdviceFactory, + UserAssigneeFactory, ) from zac.core.models import CoreConfig, MetaObjectTypesConfig from zac.core.tests.utils import ClearCachesMixin @@ -38,6 +42,7 @@ class ReviewRequestsTests(ESMixin, ClearCachesMixin, APITestCase): @classmethod def setUpTestData(cls): + cls.maxDiff = None super().setUpTestData() Service.objects.create(api_type=APITypes.ztc, api_root=CATALOGI_ROOT) Service.objects.create(api_type=APITypes.zrc, api_root=ZAKEN_ROOT) @@ -58,8 +63,6 @@ def setUpTestData(cls): meta_config.save() cls.user = UserFactory.create() - cls.group_1 = GroupFactory.create() - cls.group_2 = GroupFactory.create() cls.catalogus = generate_oas_component( "ztc", "schemas/Catalogus", @@ -88,15 +91,24 @@ def setUpTestData(cls): cls.endpoint = reverse( "werkvoorraad:review-requests", ) - - cls.group = GroupFactory.create(name="some-group") - # Let resolve_assignee get the right users and groups - UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][0]["userAssignees"][0] + user_assignees = UserAssigneeFactory( + **{ + "username": "some-other-author", + "first_name": "Some Other First", + "last_name": "Some Last", + "full_name": "Some Other First Some Last", + } ) - UserFactory.create( - username=REVIEW_REQUEST["assignedUsers"][1]["userAssignees"][0] + assigned_users2 = AssignedUsersFactory( + **{ + "deadline": "2022-04-15", + "user_assignees": [user_assignees], + "group_assignees": [], + "email_notification": False, + } ) + cls.review_request = ReviewRequestFactory() + cls.review_request["assignedUsers"].append(assigned_users2) @patch("zac.core.services.fetch_objecttypes", return_value=[]) def test_workstack_review_requests_endpoint_no_zaak(self, m, *mocks): @@ -104,11 +116,12 @@ def test_workstack_review_requests_endpoint_no_zaak(self, m, *mocks): mock_service_oas_get(m, OBJECTS_ROOT, "objects") mock_service_oas_get(m, OBJECTTYPES_ROOT, "objecttypes") mock_resource_get(m, self.catalogus) - self.refresh_index() + rr_object = deepcopy(REVIEW_REQUEST_OBJECT) + rr_object["record"]["data"] = self.review_request m.post( f"{OBJECTS_ROOT}objects/search?pageSize=20&page=1", - json=paginated_response([REVIEW_REQUEST_OBJECT]), + json=paginated_response([rr_object]), ) self.client.force_authenticate(user=self.user) @@ -127,21 +140,31 @@ def test_workstack_review_requests_endpoint_no_zaak(self, m, *mocks): "previous": None, "results": [ { - "id": REVIEW_REQUEST["id"], - "reviewType": REVIEW_REQUEST["reviewType"], + "id": self.review_request["id"], + "reviewType": self.review_request["reviewType"], "openReviews": [ { "deadline": "2022-04-14", "groups": [], - "users": ["Some First Some Last"], + "users": [ + self.review_request["assignedUsers"][0][ + "userAssignees" + ][0]["fullName"] + ], }, { "deadline": "2022-04-15", "groups": [], - "users": ["Some Other First Some Last"], + "users": [ + self.review_request["assignedUsers"][1][ + "userAssignees" + ][0]["fullName"] + ], }, ], - "isBeingReconfigured": REVIEW_REQUEST["isBeingReconfigured"], + "isBeingReconfigured": self.review_request[ + "isBeingReconfigured" + ], "completed": 0, "zaak": None, "advices": [], @@ -162,16 +185,25 @@ def test_workstack_review_requests_endpoint_found_zaak(self, m, *mocks): zaak_document.save() self.refresh_index() + rr_object = deepcopy(REVIEW_REQUEST_OBJECT) + rr_object["record"]["data"] = self.review_request m.post( f"{OBJECTS_ROOT}objects/search?pageSize=20&page=1", - json=paginated_response([REVIEW_REQUEST_OBJECT]), + json=paginated_response([rr_object]), ) self.client.force_authenticate(user=self.user) + advice = AdviceFactory() + reviews_advice = ReviewsAdviceFactory() + reviews_advice["reviews"] = [advice] + + review_object = deepcopy(REVIEW_OBJECT) + review_object["record"]["data"] = reviews_advice + with patch( "zac.contrib.objects.services.fetch_reviews", - return_value=[REVIEW_OBJECT], + return_value=[review_object], ): response = self.client.get(self.endpoint) self.assertEqual(response.status_code, 200) @@ -182,16 +214,22 @@ def test_workstack_review_requests_endpoint_found_zaak(self, m, *mocks): "previous": None, "results": [ { - "id": REVIEW_REQUEST["id"], - "reviewType": REVIEW_REQUEST["reviewType"], + "id": self.review_request["id"], + "reviewType": self.review_request["reviewType"], "openReviews": [ { "deadline": "2022-04-15", "groups": [], - "users": ["Some Other First Some Last"], + "users": [ + self.review_request["assignedUsers"][1][ + "userAssignees" + ][0]["fullName"] + ], } ], - "isBeingReconfigured": REVIEW_REQUEST["isBeingReconfigured"], + "isBeingReconfigured": self.review_request[ + "isBeingReconfigured" + ], "completed": 1, "zaak": { "url": ZAAK_URL, @@ -216,14 +254,14 @@ def test_workstack_review_requests_endpoint_found_zaak(self, m, *mocks): "advices": [ { "author": { - "firstName": ADVICE["author"]["firstName"], - "lastName": ADVICE["author"]["lastName"], - "username": ADVICE["author"]["username"], - "fullName": ADVICE["author"]["fullName"], + "firstName": advice["author"]["firstName"], + "lastName": advice["author"]["lastName"], + "username": advice["author"]["username"], + "fullName": advice["author"]["fullName"], }, - "advice": ADVICE["advice"], + "advice": advice["advice"], "group": dict(), - "created": ADVICE["created"], + "created": advice["created"], } ], }