Skip to content

Commit

Permalink
✅ [#397] Test zaak creation with VCR
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm authored and svenvandescheur committed Oct 17, 2024
1 parent fb69999 commit ee197c7
Show file tree
Hide file tree
Showing 5 changed files with 485 additions and 4 deletions.
98 changes: 98 additions & 0 deletions backend/docker-services/openzaak/fixtures/complex_relations.json
Original file line number Diff line number Diff line change
Expand Up @@ -658,5 +658,103 @@
"catalogus": 1,
"deelzaaktypen": []
}
},
{
"model": "catalogi.informatieobjecttype",
"pk": 2,
"fields": {
"datum_begin_geldigheid": "2018-01-01",
"datum_einde_geldigheid": null,
"concept": false,
"uuid": "9dee6712-122e-464a-99a3-c16692de5485",
"omschrijving": "Destruction report type",
"informatieobjectcategorie": "stock",
"trefwoord": "[]",
"vertrouwelijkheidaanduiding": "openbaar",
"omschrijving_generiek_informatieobjecttype": "bill",
"omschrijving_generiek_definitie": "Destruction report type",
"omschrijving_generiek_herkomst": "ZSWuoDPOIaWF",
"omschrijving_generiek_hierarchie": "until",
"omschrijving_generiek_opmerking": "",
"catalogus": 1
}
},
{
"model": "catalogi.zaaktypeinformatieobjecttype",
"pk": 2,
"fields": {
"uuid": "835af306-c038-42f5-8225-008628b6e3f8",
"zaaktype": 2,
"informatieobjecttype": 2,
"volgnummer": 1,
"richting": "inkomend",
"statustype": null
}
},
{
"model": "catalogi.zaaktype",
"pk": 2,
"fields": {
"datum_begin_geldigheid": "2018-01-01",
"datum_einde_geldigheid": null,
"concept": false,
"uuid": "ecd08880-5081-4d7a-afc3-ade1d6e6346f",
"identificatie": "ZAAKTYPE-2018-0000000002",
"zaaktype_omschrijving": "Destruction confirmation type",
"zaaktype_omschrijving_generiek": "",
"vertrouwelijkheidaanduiding": "",
"doel": "To confirm that a destruction list has been correctly processed.",
"aanleiding": "When a destructio list is processed by Open Archiefbeheer",
"toelichting": "",
"indicatie_intern_of_extern": "extern",
"handeling_initiator": "indienen",
"onderwerp": "Destruction",
"handeling_behandelaar": "uitvoeren",
"doorlooptijd_behandeling": "P30D",
"servicenorm_behandeling": null,
"opschorting_en_aanhouding_mogelijk": true,
"verlenging_mogelijk": false,
"verlengingstermijn": null,
"trefwoorden": "[]",
"publicatie_indicatie": true,
"publicatietekst": "",
"verantwoordingsrelatie": "[]",
"versiedatum": "2018-01-01",
"verantwoordelijke": "100000000",
"producten_of_diensten": "[\"https://example.com/product/123\"]",
"selectielijst_procestype": "https://selectielijst.openzaak.nl/api/v1/procestypen/c844637e-6393-4202-b030-e1bffb08a9b0",
"selectielijst_procestype_jaar": 2020,
"referentieproces_naam": "ReferentieProces 0",
"referentieproces_link": "",
"broncatalogus_url": "",
"broncatalogus_domein": "",
"broncatalogus_rsin": "",
"bronzaaktype_url": "",
"bronzaaktype_identificatie": "",
"bronzaaktype_omschrijving": "",
"catalogus": 1,
"deelzaaktypen": []
}
},
{
"model": "catalogi.statustype",
"pk": 1,
"fields": {
"uuid": "835a2a13-f52f-4339-83e5-b7250e5ad016",
"statustype_omschrijving": "Statustype for destruction report zaak",
"statustypevolgnummer": 1,
"zaaktype": 2
}
},
{
"model": "catalogi.resultaattype",
"pk": 1,
"fields": {
"uuid": "5d39b8ac-437a-475c-9a76-0f6ae1540d0e",
"omschrijving": "Destruction report zaak",
"resultaattypeomschrijving": "Destruction report zaak",
"selectielijstklasse": "https://selectielijst.openzaak.nl/api/v1/resultaten/1bb001e9-5eab-4f10-8940-8781e11f180f",
"zaaktype": 2
}
}
]
7 changes: 7 additions & 0 deletions backend/src/openarchiefbeheer/destruction/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ class Meta:
model = "destruction.DestructionList"
django_get_or_create = ("name",)

class Params:
with_report = factory.Trait(
destruction_report=factory.django.FileField(
data=b"some data", filename="report.csv"
),
)

@post_generation
def post(destruction_list, create, extracted, **kwargs):
if not create:
Expand Down
37 changes: 33 additions & 4 deletions backend/src/openarchiefbeheer/destruction/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,18 @@ def test_process_list(self):
destruction_list=destruction_list,
)

with patch(
"openarchiefbeheer.destruction.models.delete_zaak_and_related_objects"
) as m_delete:
with (
patch(
"openarchiefbeheer.destruction.models.delete_zaak_and_related_objects"
) as m_delete,
patch(
"openarchiefbeheer.destruction.utils.create_zaak_for_report"
) as m_zaak,
patch(
"openarchiefbeheer.destruction.utils.create_eio_destruction_report"
) as m_eio,
patch("openarchiefbeheer.destruction.utils.attach_report_to_zaak") as m_zio,
):
delete_destruction_list(destruction_list)

destruction_list.refresh_from_db()
Expand Down Expand Up @@ -324,6 +333,10 @@ def test_process_list(self):
b"http://zaken.nl/api/v1/zaken/222-222-222,2022-01-02,http://zaken.nl/api/v1/resultaten/111-111-222,2020-01-02,Test description 2,ZAAK-02,http://catalogue-api.nl/zaaktypen/111-111-111,Aangifte behandelen,1\n",
)

m_zaak.assert_called()
m_eio.assert_called()
m_zio.assert_called()

@log_capture(level=logging.INFO)
def test_item_skipped_if_already_succeeded(self, logs):
item = DestructionListItemFactory.create(
Expand Down Expand Up @@ -358,6 +371,13 @@ def test_processing_list_with_failed_item(self):
patch(
"openarchiefbeheer.destruction.models.delete_zaak_and_related_objects",
),
patch(
"openarchiefbeheer.destruction.utils.create_zaak_for_report"
) as m_zaak,
patch(
"openarchiefbeheer.destruction.utils.create_eio_destruction_report"
) as m_eio,
patch("openarchiefbeheer.destruction.utils.attach_report_to_zaak") as m_zio,
):
delete_destruction_list(destruction_list)

Expand All @@ -371,9 +391,18 @@ def test_processing_list_with_failed_item(self):
self.assertEqual(item.processing_status, InternalStatus.succeeded)
self.assertEqual(
item.internal_results,
{"deleted_resources": {}, "resources_to_delete": {}, "traceback": ""},
{
"deleted_resources": {},
"resources_to_delete": {},
"traceback": "",
"created_resources": {},
},
)

m_zaak.assert_called()
m_eio.assert_called()
m_zio.assert_called()

def test_complete_and_notify(self):
destruction_list = DestructionListFactory.create(
name="Some destruction list",
Expand Down
Loading

0 comments on commit ee197c7

Please sign in to comment.