Skip to content

Commit

Permalink
✅ [#499] Test logging when review processed
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Nov 26, 2024
1 parent a4c030e commit 0487746
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from rest_framework import status
from rest_framework.reverse import reverse
from rest_framework.test import APITestCase
from timeline_logger.models import TimelineLog

from openarchiefbeheer.accounts.tests.factories import UserFactory

Expand Down Expand Up @@ -56,6 +57,10 @@ def test_filter_on_review(self):

def test_create_review_response(self):
record_manager = UserFactory.create(post__can_start_destruction=True)
record_manager_group, created = Group.objects.get_or_create(
name="Record Manager"
)
record_manager.groups.add(record_manager_group)
review = DestructionListReviewFactory.create(
destruction_list__author=record_manager,
destruction_list__status=ListStatus.changes_requested,
Expand Down Expand Up @@ -133,6 +138,25 @@ def test_create_review_response(self):

self.assertEqual(item_response3.action_zaak["archiefactiedatum"], "2030-01-01")

logs = TimelineLog.objects.for_object(review.destruction_list)

self.assertEqual(logs.count(), 1)

message = logs[0].get_message()

self.assertIn(
_(
"User %(author)s (member of group %(groups)s) has processed the feedback on "
'destruction list "%(list_name)s".'
)
% {
"author": str(record_manager),
"groups": "Record Manager",
"list_name": review.destruction_list.name,
},
message,
)

def test_can_create_response_if_not_author(self):
record_manager1 = UserFactory.create(post__can_start_destruction=True)
record_manager2 = UserFactory.create(post__can_start_destruction=True)
Expand Down
41 changes: 41 additions & 0 deletions backend/src/openarchiefbeheer/destruction/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

from django.core import mail
from django.test import TestCase, override_settings, tag
from django.utils.translation import gettext as _, ngettext

from freezegun import freeze_time
from privates.test import temp_private_root
from requests import HTTPError
from requests_mock import Mocker
from testfixtures import log_capture
from timeline_logger.models import TimelineLog
from zgw_consumers.constants import APITypes
from zgw_consumers.test.factories import ServiceFactory

Expand Down Expand Up @@ -163,6 +165,7 @@ def test_reject_suggestion_does_not_change_zaak(self, m):
zaak = ZaakFactory.create(archiefactiedatum="2025-01-01")
review_item_response = ReviewItemResponseFactory.create(
review_item__destruction_list_item__zaak=zaak,
review_item__destruction_list_item__destruction_list=review_response.review.destruction_list,
review_item__review=review_response.review,
action_item=DestructionListItemAction.keep,
action_zaak_type=ZaakActionType.bewaartermijn,
Expand Down Expand Up @@ -204,6 +207,21 @@ def test_reject_suggestion_does_not_change_zaak(self, m):
zaak.archiefactiedatum.isoformat(), "2025-01-01"
) # NOT changed!!

logs = TimelineLog.objects.for_object(review_response.review.destruction_list)

self.assertEqual(logs.count(), 1)

message = logs[0].get_message()

self.assertIn(
_(
'The review response of destruction list "%(list_name)s" has been processed.'
)
% {"list_name": review_response.review.destruction_list.name},
message,
)
self.assertIn(_("There is now one zaak on the list."), message)

def test_prepopulating_selection(self, m):
destruction_list = DestructionListFactory.create(
status=ListStatus.changes_requested
Expand Down Expand Up @@ -275,6 +293,29 @@ def test_prepopulating_selection(self, m):
self.assertNotIn("detail", selection_items[0].selection_data)
self.assertFalse(selection_items[0].selection_data["selected"])

logs = TimelineLog.objects.for_object(destruction_list)

self.assertEqual(logs.count(), 1)

message = logs[0].get_message()

self.assertIn(
_(
'The review response of destruction list "%(list_name)s" has been processed.'
)
% {"list_name": review_response.review.destruction_list.name},
message,
)
self.assertIn(
ngettext(
"There is now one zaak on the list.",
"There are now %(number_of_zaken)s zaken on the list.",
2,
)
% {"number_of_zaken": 2},
message,
)


@temp_private_root()
class ProcessDeletingZakenTests(TestCase):
Expand Down

0 comments on commit 0487746

Please sign in to comment.