Skip to content

Commit

Permalink
✅ [#554] Improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Jan 7, 2025
1 parent dbd3d4a commit 20eabd2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions backend/src/openarchiefbeheer/destruction/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from django.core.exceptions import ObjectDoesNotExist
from django.test import TestCase

from timeline_logger.models import TimelineLog

from openarchiefbeheer.accounts.tests.factories import UserFactory
from openarchiefbeheer.zaken.tests.factories import ZaakFactory

from ..constants import ListRole
from ..models import DestructionListItem
from ..utils import process_new_reviewer, resync_items_and_zaken
from .factories import (
DestructionListAssigneeFactory,
Expand Down Expand Up @@ -48,12 +52,20 @@ def test_resync_zaken_missing(self):
ZaakFactory.create(url="http://zaken.nl/2")
item1 = DestructionListItemFactory.create(_zaak_url="http://zaken.nl/1")
item2 = DestructionListItemFactory.create(_zaak_url="http://zaken.nl/3")
item2_pk = item2.pk
destruction_list2 = item2.destruction_list

resync_items_and_zaken()

item1.refresh_from_db()
item2.refresh_from_db()

self.assertIsNotNone(item1.zaak)
self.assertEqual(item1.zaak.url, "http://zaken.nl/1")
self.assertIsNone(item2.zaak)
with self.assertRaises(ObjectDoesNotExist):
DestructionListItem.objects.get(pk=item2_pk)

logs = TimelineLog.objects.for_object(destruction_list2)

self.assertEqual(logs.count(), 1)
self.assertEqual(logs[0].extra_data["number_deleted_items"], 1)
self.assertEqual(logs[0].extra_data["number_of_zaken"], 0)

0 comments on commit 20eabd2

Please sign in to comment.