def test_failed_destruction_not_in_report_content(self, m_vcs, m_zaaktype): destruction_list = DestructionListFactory.create( status=ListStatus.processing, contains_sensitive_info=False, ) DestructionListItemFactory.create( destruction_list=destruction_list, status=ListItemStatus.failed, extra_zaak_data={ "identificatie": "ZAAK-1", "omschrijving": "Een zaak", "toelichting": "Bah", "startdatum": "2020-01-01", "einddatum": "2021-01-01", "zaaktype": "https://oz.nl/catalogi/api/v1/zaaktypen/uuid-1", "verantwoordelijke_organisatie": "Nicer organisation", "resultaat": { "resultaattype": { "omschrijving": "Nicer result type", "archiefactietermijn": "40 days", } }, "relevante_andere_zaken": [{ "url": "http://some.zaak" }], }, ) DestructionListItemFactory.create( destruction_list=destruction_list, status=ListItemStatus.destroyed, extra_zaak_data={ "identificatie": "ZAAK-2", "omschrijving": "Een andere zaak", "toelichting": "", "startdatum": "2020-02-01", "einddatum": "2021-03-01", "zaaktype": "https://oz.nl/catalogi/api/v1/zaaktypen/uuid-2", "verantwoordelijke_organisatie": "Nice organisation", "resultaat": { "resultaattype": { "omschrijving": "Nice result type", "archiefactietermijn": "20 days", } }, "relevante_andere_zaken": [], }, ) report_data = get_destruction_report_data(destruction_list) self.assertEqual(1, len(report_data)) self.assertEqual("ZAAK-2", report_data[0]["identificatie"])
def test_destruction_report_content_generation_without_toelichting( self, m_vcs, m_zaaktype): destruction_list = DestructionListFactory.create( contains_sensitive_info=False) DestructionListItemFactory.create( destruction_list=destruction_list, status=ListItemStatus.destroyed, extra_zaak_data={ "identificatie": "ZAAK-1", "omschrijving": "Een zaak", "startdatum": "2020-01-01", "einddatum": "2021-01-01", "zaaktype": "https://oz.nl/catalogi/api/v1/zaaktypen/uuid-1", "verantwoordelijke_organisatie": "Nicer organisation", "resultaat": { "resultaattype": { "omschrijving": "Nicer result type", "archiefactietermijn": "40 days", } }, "relevante_andere_zaken": [{ "url": "http://some.zaak" }], }, ) report_data = get_destruction_report_data(destruction_list) self.assertEqual(1, len(report_data)) # Test sensitive info self.assertIn("omschrijving", report_data[0]) self.assertIn("opmerkingen", report_data[0]) # Test remaining info self.assertEqual("ZAAK-1", report_data[0]["identificatie"]) self.assertEqual("Een zaak", report_data[0]["omschrijving"]) self.assertEqual("366 days", report_data[0]["looptijd"]) self.assertEqual("1", report_data[0]["vernietigings_categorie"]) self.assertNotIn("toelichting", report_data[0]) self.assertEqual("", report_data[0]["opmerkingen"]) self.assertEqual("", report_data[0]["reactie_zorgdrager"]) self.assertEqual("This is a zaaktype", report_data[0]["zaaktype"]) self.assertEqual("40 days", report_data[0]["archiefactietermijn"]) self.assertEqual("Nicer result type", report_data[0]["resultaattype"]) self.assertEqual("Nicer organisation", report_data[0]["verantwoordelijke_organisatie"]) self.assertEqual("Yes", report_data[0]["relaties"])
def test_destruction_report_data_with_sensitive_info(self): destruction_list = DestructionListFactory.create( name="Winter cases", contains_sensitive_info=True, ) DestructionListItemFactory.create( destruction_list=destruction_list, status=ListItemStatus.destroyed, extra_zaak_data={ "identificatie": "ZAAK-1", "omschrijving": "Een zaak", "toelichting": "Bah", "startdatum": "2020-01-01", "einddatum": "2021-01-01", "zaaktype": "https://oz.nl/catalogi/api/v1/zaaktypen/uuid-1", "verantwoordelijke_organisatie": "Nicer organisation", "resultaat": { "resultaattype": { "omschrijving": "Nicer result type", "archiefactietermijn": "40 days", } }, "relevante_andere_zaken": [{ "url": "http://some.zaak" }], }, ) archivaris = UserFactory.create( role__type=RoleTypeChoices.archivist, role__can_start_destruction=False, role__can_review_destruction=True, role__can_view_case_details=False, ) DestructionListReviewFactory.create( destruction_list=destruction_list, status=ReviewStatus.approved, author=archivaris, text="What a magnificent list!", ) report_data = get_destruction_report_data(destruction_list) self.assertEqual(1, len(report_data)) zaak_data = report_data[0] self.assertNotIn("omschrijving", zaak_data) self.assertNotIn("opmerkingen", zaak_data)
def test_create_csv_content_without_sensitive_info(self, m_vcs, m_zaaktype): destruction_list = DestructionListFactory.create( name="Winter cases", contains_sensitive_info=False, ) DestructionListItemFactory.create( destruction_list=destruction_list, status=ListItemStatus.destroyed, extra_zaak_data={ "identificatie": "ZAAK-1", "omschrijving": "Een zaak", "toelichting": "Bah", "startdatum": "2020-01-01", "einddatum": "2021-01-01", "zaaktype": "https://oz.nl/catalogi/api/v1/zaaktypen/uuid-1", "verantwoordelijke_organisatie": "Nicer organisation", "resultaat": { "resultaattype": { "omschrijving": "Nicer result type", "archiefactietermijn": "40 days", } }, "relevante_andere_zaken": [{ "url": "http://some.zaak" }], }, ) archivaris = UserFactory.create( role__type=RoleTypeChoices.archivist, role__can_start_destruction=False, role__can_review_destruction=True, role__can_view_case_details=False, ) DestructionListReviewFactory.create( destruction_list=destruction_list, status=ReviewStatus.approved, author=archivaris, text="What a magnificent list!", ) zaken_data = get_destruction_report_data(destruction_list) html_content = create_csv_report_content( zaken_data, destruction_list.contains_sensitive_info) html_content.seek(0) lines = [line for line in html_content.readlines()] expected_header_row = [ "Unique ID", "Description", "Duration", "Destruction category Selectielijst", "Explanation", "Remarks SAD", "Reaction caretaker", "Case type", "Archive action period", "Result type", "Organisation responsible", "Relations", ] expected_zaak_row = [ "ZAAK-1", "Een zaak", "366 days", "1", "Bah", "What a magnificent list!", "", "This is a zaaktype", "40 days", "Nicer result type", "Nicer organisation", "Yes", ] self.assertEqual(2, len(lines)) for header in expected_header_row: self.assertIn(header, lines[0]) for zaak in expected_zaak_row: self.assertIn(zaak, lines[1])
def test_create_html_content_without_sensitive_info( self, m_vcs, m_zaaktype): destruction_list = DestructionListFactory.create( name="Winter cases", contains_sensitive_info=False, ) DestructionListItemFactory.create( destruction_list=destruction_list, status=ListItemStatus.destroyed, extra_zaak_data={ "identificatie": "ZAAK-1", "omschrijving": "Een zaak", "toelichting": "Bah", "startdatum": "2020-01-01", "einddatum": "2021-01-01", "zaaktype": "https://oz.nl/catalogi/api/v1/zaaktypen/uuid-1", "verantwoordelijke_organisatie": "Nicer organisation", "resultaat": { "resultaattype": { "omschrijving": "Nicer result type", "archiefactietermijn": "40 days", } }, "relevante_andere_zaken": [{ "url": "http://some.zaak" }], }, ) archivaris = UserFactory.create( role__type=RoleTypeChoices.archivist, role__can_start_destruction=False, role__can_review_destruction=True, role__can_view_case_details=False, ) DestructionListReviewFactory.create( destruction_list=destruction_list, status=ReviewStatus.approved, author=archivaris, text="What a magnificent list!", ) zaken_data = get_destruction_report_data(destruction_list) html_content = create_html_report_content( zaken_data, destruction_list.contains_sensitive_info) expected_html_nodes = [ "<th>Unique ID</th>", "<th>Description</th>", "<th>Duration</th>", "<th>Destruction category Selectielijst</th>", "<th>Explanation</th>", "<th>Reaction caretaker</th>", "<th>Remarks SAD</th>", "<th>Case type</th>", "<th>Archive action period</th>", "<th>Result type</th>", "<th>Organisation responsible</th>", "<th>Relations</th>", "<td>Een zaak</td>", "<td>ZAAK-1</td>", "<td>What a magnificent list!</td>", "<td>366 days</td>", "<td>1</td>", "<td>Bah</td>", "<td></td>", "<td>This is a zaaktype</td>", "<td>40 days</td>", "<td>Nicer result type</td>", "<td>Nicer organisation</td>", "<td>Yes</td>", ] for node in expected_html_nodes: self.assertIn(node, html_content)
def test_destruction_report_data_without_sensitive_info( self, m_vcs, m_zaaktype): destruction_list = DestructionListFactory.create( name="Winter cases", contains_sensitive_info=False, ) DestructionListItemFactory.create( destruction_list=destruction_list, status=ListItemStatus.destroyed, extra_zaak_data={ "identificatie": "ZAAK-1", "omschrijving": "Een zaak", "toelichting": "Bah", "startdatum": "2020-01-01", "einddatum": "2021-01-01", "zaaktype": "https://oz.nl/catalogi/api/v1/zaaktypen/uuid-1", "verantwoordelijke_organisatie": "Nicer organisation", "resultaat": { "resultaattype": { "omschrijving": "Nicer result type", "archiefactietermijn": "40 days", } }, "relevante_andere_zaken": [{ "url": "http://some.zaak" }], }, ) DestructionListItemFactory.create( destruction_list=destruction_list, status=ListItemStatus.destroyed, extra_zaak_data={ "identificatie": "ZAAK-2", "omschrijving": "Een andere zaak", "toelichting": "Boh", "startdatum": "2020-02-01", "einddatum": "2021-03-01", "zaaktype": "https://oz.nl/catalogi/api/v1/zaaktypen/uuid-2", "verantwoordelijke_organisatie": "Nice organisation", "resultaat": { "resultaattype": { "omschrijving": "Nice result type", "archiefactietermijn": "20 days", } }, "relevante_andere_zaken": [], }, ) archivaris = UserFactory.create( role__type=RoleTypeChoices.archivist, role__can_start_destruction=False, role__can_review_destruction=True, role__can_view_case_details=False, ) DestructionListReviewFactory.create( destruction_list=destruction_list, status=ReviewStatus.approved, author=archivaris, text="What a magnificent list!", ) report_data = get_destruction_report_data(destruction_list) self.assertEqual(2, len(report_data)) # Test sensitive info self.assertIn("omschrijving", report_data[0]) self.assertIn("opmerkingen", report_data[0]) self.assertIn("omschrijving", report_data[1]) self.assertIn("opmerkingen", report_data[1]) # Test remaining info self.assertEqual("ZAAK-1", report_data[0]["identificatie"]) self.assertEqual("Een zaak", report_data[0]["omschrijving"]) self.assertEqual("366 days", report_data[0]["looptijd"]) self.assertEqual("1", report_data[0]["vernietigings_categorie"]) self.assertEqual("Bah", report_data[0]["toelichting"]) self.assertEqual("What a magnificent list!", report_data[0]["opmerkingen"]) self.assertEqual("", report_data[0]["reactie_zorgdrager"]) self.assertEqual("This is a zaaktype", report_data[0]["zaaktype"]) self.assertEqual("40 days", report_data[0]["archiefactietermijn"]) self.assertEqual("Nicer result type", report_data[0]["resultaattype"]) self.assertEqual("Nicer organisation", report_data[0]["verantwoordelijke_organisatie"]) self.assertEqual("Yes", report_data[0]["relaties"]) # Test remaining info self.assertEqual("ZAAK-2", report_data[1]["identificatie"]) self.assertEqual("Een andere zaak", report_data[1]["omschrijving"]) self.assertEqual("394 days", report_data[1]["looptijd"]) self.assertEqual("1", report_data[1]["vernietigings_categorie"]) self.assertEqual("Boh", report_data[1]["toelichting"]) self.assertEqual("What a magnificent list!", report_data[1]["opmerkingen"]) self.assertEqual("", report_data[1]["reactie_zorgdrager"]) self.assertEqual("This is a zaaktype", report_data[1]["zaaktype"]) self.assertEqual("20 days", report_data[1]["archiefactietermijn"]) self.assertEqual("Nice result type", report_data[1]["resultaattype"]) self.assertEqual("Nice organisation", report_data[1]["verantwoordelijke_organisatie"]) self.assertEqual("No", report_data[1]["relaties"])