|
1 | | -import os |
2 | 1 | from datetime import timedelta |
3 | 2 |
|
4 | | -from django.core.files.base import ContentFile |
5 | 3 | from django.utils import timezone |
6 | 4 | from django.test import TestCase |
7 | 5 |
|
@@ -46,31 +44,6 @@ def test_exports_older_than_30_minutes_are_deleted(self): |
46 | 44 | SubmissionExportTask.objects.filter(uid=recent_export.uid).exists() |
47 | 45 | ) |
48 | 46 |
|
49 | | - def test_export_result_file_is_deleted_from_storage(self): |
50 | | - """ |
51 | | - Test that export files are deleted from storage |
52 | | - """ |
53 | | - export = self._create_export_task(minutes_old=60) |
54 | | - |
55 | | - # Create actual file in storage |
56 | | - file_content = ContentFile( |
57 | | - b'PK\x03\x04' + |
58 | | - b'{"data": "export"}' * 100, |
59 | | - name='test_export.xlsx' |
60 | | - ) |
61 | | - export.result.save(f'test_export_{export.uid}.xlsx', file_content, save=True) |
62 | | - export.refresh_from_db() |
63 | | - |
64 | | - storage = export.result.storage |
65 | | - file_path = storage.path(export.result.name) |
66 | | - self.assertTrue(os.path.exists(file_path)) |
67 | | - self.assertTrue(SubmissionExportTask.objects.filter(uid=export.uid).exists()) |
68 | | - |
69 | | - cleanup_anonymous_exports() |
70 | | - |
71 | | - self.assertFalse(os.path.exists(file_path)) |
72 | | - self.assertFalse(SubmissionExportTask.objects.filter(uid=export.uid).exists()) |
73 | | - |
74 | 47 | def test_processing_exports_are_not_deleted(self): |
75 | 48 | """ |
76 | 49 | Test that exports with PROCESSING status are never deleted |
|
0 commit comments