From 5c583f2b1c2029067da17827d65cb8b9f8645627 Mon Sep 17 00:00:00 2001 From: SilviaAmAm Date: Tue, 24 Dec 2024 14:26:38 +0100 Subject: [PATCH] :white_check_mark: [#557] Test deleting local destruction report --- .../destruction/tests/test_models.py | 13 +++++++++++++ .../destruction/tests/test_tasks.py | 4 ---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/backend/src/openarchiefbeheer/destruction/tests/test_models.py b/backend/src/openarchiefbeheer/destruction/tests/test_models.py index dc17222f..1e13aced 100644 --- a/backend/src/openarchiefbeheer/destruction/tests/test_models.py +++ b/backend/src/openarchiefbeheer/destruction/tests/test_models.py @@ -1,8 +1,10 @@ +import os from datetime import date, datetime from unittest.mock import patch from django.contrib.auth.models import Group from django.core.exceptions import ObjectDoesNotExist +from django.core.files.base import ContentFile from django.test import TestCase from django.utils import timezone from django.utils.translation import gettext @@ -965,7 +967,15 @@ def test_clean_local_metadata(self): destruction_list = DestructionListFactory.create( processing_status=InternalStatus.succeeded, status=ListStatus.deleted, + destruction_report=ContentFile( + b"Hello I am a report.", name="report_test.txt" + ), ) + + path = destruction_list.destruction_report.path + self.assertIsNotNone(destruction_list.destruction_report) + self.assertTrue(os.path.isfile(path)) + item1 = DestructionListItemFactory.create( processing_status=InternalStatus.succeeded, destruction_list=destruction_list, @@ -1012,6 +1022,9 @@ def test_clean_local_metadata(self): self.assertEqual(item1.extra_zaak_data, {}) self.assertEqual(item2.extra_zaak_data, {}) + with self.assertRaises(ValueError): + destruction_list.destruction_report.file + self.assertFalse(os.path.isfile(path)) class DestructionListCoReviewTest(TestCase): diff --git a/backend/src/openarchiefbeheer/destruction/tests/test_tasks.py b/backend/src/openarchiefbeheer/destruction/tests/test_tasks.py index b36945ad..428aa77a 100644 --- a/backend/src/openarchiefbeheer/destruction/tests/test_tasks.py +++ b/backend/src/openarchiefbeheer/destruction/tests/test_tasks.py @@ -651,10 +651,6 @@ def test_complete_and_notify(self): self.assertEqual(destruction_list.status, ListStatus.deleted) self.assertEqual(destruction_list.processing_status, InternalStatus.succeeded) - self.assertEqual( - destruction_list.destruction_report.name, - "destruction_reports/2024/10/09/report_some-destruction-list.xlsx", - ) self.assertEqual( destruction_list.end.astimezone( tz=timezone.get_default_timezone()