Skip to content

Commit 7c0f1e5

Browse files
SilviaAmAmsvenvandescheur
authored andcommittedSep 3, 2024
✅ [#296] Test new _zaak_url field
1 parent 5340da9 commit 7c0f1e5

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
 

‎backend/src/openarchiefbeheer/destruction/tests/test_migrations.py

+35
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,38 @@ def test_zaak_url_repopulated(self):
141141
self.assertEqual(items[0].zaak_url, "http://zaken.nl/api/v1/zaken/111-111-111")
142142
self.assertEqual(items[1].zaak_url, "http://zaken.nl/api/v1/zaken/222-222-222")
143143
self.assertEqual(items[2].zaak_url, "http://zaken.nl/api/v1/zaken/333-333-333")
144+
145+
146+
class TestAddZaakUrlMigration(TestMigrations):
147+
app = "destruction"
148+
migrate_from = "0019_destructionlistitem__zaak_url"
149+
migrate_to = "0020_auto_20240822_1113"
150+
151+
def setUpBeforeMigration(self, apps):
152+
Zaak = apps.get_model("zaken", "Zaak")
153+
DestructionListItem = apps.get_model("destruction", "DestructionListItem")
154+
DestructionList = apps.get_model("destruction", "DestructionList")
155+
User = apps.get_model("accounts", "User")
156+
157+
zaak1 = Zaak.objects.create(
158+
uuid=str(uuid4()),
159+
url="http://zaken.nl/api/v1/zaken/111-111-111",
160+
startdatum=date(2000, 1, 1),
161+
zaaktype="http://catalogue-api.nl/zaaktypen/111-111-111",
162+
bronorganisatie="000000000",
163+
verantwoordelijke_organisatie="000000000",
164+
)
165+
destruction_list = DestructionList.objects.create(
166+
name="Test migration",
167+
author=User.objects.create(username="recordmanager"),
168+
)
169+
self.item = DestructionListItem.objects.create(
170+
zaak=zaak1,
171+
status=ListItemStatus.suggested,
172+
destruction_list_id=destruction_list.pk,
173+
)
174+
175+
def test_added_zaak_url(self):
176+
self.item.refresh_from_db()
177+
178+
self.assertEqual(self.item.zaak.url, self.item._zaak_url)

‎backend/src/openarchiefbeheer/destruction/tests/test_models.py

+16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from openarchiefbeheer.config.models import ArchiveConfig
1111
from openarchiefbeheer.zaken.models import Zaak
12+
from openarchiefbeheer.zaken.tests.factories import ZaakFactory
1213

1314
from ..constants import InternalStatus, ListItemStatus
1415
from .factories import (
@@ -68,6 +69,21 @@ def test_process_deletion(self):
6869
with self.assertRaises(ObjectDoesNotExist):
6970
Zaak.objects.get(url="http://zaken.nl/api/v1/zaken/111-111-111")
7071

72+
def test_keeping_zaak_url_in_sync(self):
73+
zaak = ZaakFactory.create(url="http://zaken.nl/1")
74+
item = DestructionListItemFactory.create(
75+
with_zaak=True, zaak__url="http://zaken.nl/2"
76+
)
77+
78+
self.assertEqual(item._zaak_url, "http://zaken.nl/2")
79+
80+
item.zaak = zaak
81+
item.save()
82+
83+
item.refresh_from_db()
84+
85+
self.assertEqual(item._zaak_url, "http://zaken.nl/1")
86+
7187

7288
class ReviewResponseTests(TestCase):
7389
def test_derive_status(self):

0 commit comments

Comments
 (0)
Please sign in to comment.