From c4e147e10715023e4f795daf6a60237770b87dd8 Mon Sep 17 00:00:00 2001 From: SilviaAmAm Date: Tue, 14 May 2024 13:28:02 +0200 Subject: [PATCH] :white_check_mark: [#15] Update tests --- .../zaken/tests/test_tasks.py | 14 +++++--- .../zaken/tests/test_viewsets.py | 32 ++++++++++++------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/backend/src/openarchiefbeheer/zaken/tests/test_tasks.py b/backend/src/openarchiefbeheer/zaken/tests/test_tasks.py index 1248d709e..992da40b0 100644 --- a/backend/src/openarchiefbeheer/zaken/tests/test_tasks.py +++ b/backend/src/openarchiefbeheer/zaken/tests/test_tasks.py @@ -179,19 +179,23 @@ def test_expanded_correctly(self, m): zaak_with_resultaat = Zaak.objects.get(identificatie="ZAAK-01") - self.assertEqual(zaak_with_resultaat.resultaat["toelichting"], "Test result") self.assertEqual( - zaak_with_resultaat.resultaat["resultaattype"], + zaak_with_resultaat._expand["resultaat"]["toelichting"], "Test result" + ) + self.assertEqual( + zaak_with_resultaat._expand["resultaat"]["_expand"]["resultaattype"], { "url": "http://catalogue-api.nl/catalogi/api/v1/resultaattypen/bd84c463-fa65-46ef-8a9e-dd887e005aea", }, ) self.assertEqual( - zaak_with_resultaat.zaaktype["url"], + zaak_with_resultaat._expand["zaaktype"]["url"], "http://catalogue-api.nl/zaaktypen/111-111-111", ) self.assertEqual( - zaak_with_resultaat.zaaktype["selectielijst_procestype"]["nummer"], + zaak_with_resultaat._expand["zaaktype"]["selectielijst_procestype"][ + "nummer" + ], 1, ) @@ -244,6 +248,6 @@ def test_expand_no_selectielijst_service(self, m): zaak = Zaak.objects.get(identificatie="ZAAK-01") self.assertEqual( - zaak.zaaktype["selectielijst_procestype"], + zaak._expand["zaaktype"]["selectielijst_procestype"], "https://selectielijst.openzaak.nl/api/v1/procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d", ) diff --git a/backend/src/openarchiefbeheer/zaken/tests/test_viewsets.py b/backend/src/openarchiefbeheer/zaken/tests/test_viewsets.py index 59f373fb5..e61d2e994 100644 --- a/backend/src/openarchiefbeheer/zaken/tests/test_viewsets.py +++ b/backend/src/openarchiefbeheer/zaken/tests/test_viewsets.py @@ -94,9 +94,14 @@ def test_using_query_params_to_filter(self): def test_filter_resultaattype(self): zaak_1 = ZaakFactory.create( - resultaat={ - "resultaattype": { - "url": "http://catalogue-api.nl/catalogi/api/v1/resultaattypen/111-111-111" + _expand={ + "resultaat": { + "resultaattype": "http://catalogue-api.nl/catalogi/api/v1/resultaattypen/111-111-111", + "_expand": { + "resultaattype": { + "url": "http://catalogue-api.nl/catalogi/api/v1/resultaattypen/111-111-111" + } + }, } } ) @@ -105,9 +110,14 @@ def test_filter_resultaattype(self): ) # Not expanded ZaakFactory.create_batch( 2, - resultaat={ - "resultaattype": { - "url": "http://catalogue-api.nl/catalogi/api/v1/resultaattypen/222-222-222" + _expand={ + "resultaat": { + "resultaattype": "http://catalogue-api.nl/catalogi/api/v1/resultaattypen/222-222-222", + "_expand": { + "resultaattype": { + "url": "http://catalogue-api.nl/catalogi/api/v1/resultaattypen/222-222-222" + } + }, } }, ) @@ -115,7 +125,7 @@ def test_filter_resultaattype(self): user = UserFactory(username="record_manager", role__can_start_destruction=True) endpoint = furl(reverse("api:zaken-list")) - endpoint.args["resultaat__resultaattype__url"] = ( + endpoint.args["_expand__resultaat__resultaattype"] = ( "http://catalogue-api.nl/catalogi/api/v1/resultaattypen/111-111-111" ) @@ -129,13 +139,13 @@ def test_filter_resultaattype(self): def test_filter_bewaartermijn(self): zaak_1 = ZaakFactory.create( - resultaat={"resultaattype": {"archiefactietermijn": "P1D"}} + _expand={"resultaat": {"resultaattype": {"archiefactietermijn": "P1D"}}} ) ZaakFactory.create( resultaat="http://zaken-api.nl/zaken/api/v1/resultaten/111-111-111" ) # Not expanded ZaakFactory.create_batch( - 2, resultaat={"resultaattype": {"archiefactietermijn": "P2D"}} + 2, _expand={"resultaat": {"resultaattype": {"archiefactietermijn": "P2D"}}} ) user = UserFactory(username="record_manager", role__can_start_destruction=True) @@ -152,13 +162,13 @@ def test_filter_bewaartermijn(self): def test_filter_vcs(self): zaak_1 = ZaakFactory.create( - zaaktype={"selectielijst_procestype": {"nummer": 1}} + _expand={"zaaktype": {"selectielijst_procestype": {"nummer": 1}}} ) ZaakFactory.create( zaaktype="http://catalogue-api.nl/zaaktypen/111-111-111", ) # Not expanded ZaakFactory.create_batch( - 2, zaaktype={"selectielijst_procestype": {"nummer": 2}} + 2, _expand={"zaaktype": {"selectielijst_procestype": {"nummer": 2}}} ) user = UserFactory(username="record_manager", role__can_start_destruction=True)