From 90c8208e4f85c0826437576c8aa20a52871a8032 Mon Sep 17 00:00:00 2001 From: Tessa Alexander Date: Wed, 6 Nov 2024 00:33:35 +0000 Subject: [PATCH] Add further debug output and fallback mimetpye check --- tests/test_uploads.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_uploads.py b/tests/test_uploads.py index f67029e..1a3b993 100644 --- a/tests/test_uploads.py +++ b/tests/test_uploads.py @@ -113,8 +113,12 @@ def _assert_file_is_uploaded_and_extracted_where_required(self, test_archive_fil self.assertNotContains(response, "is not a plain text file") self.assertEqual(Upload.objects.all().count(), previous_upload_count + 1) uploaded_file_path = Upload.objects.all().order_by("id").last().abstracts_upload.path - logger.error(f"uploaded_file_path {uploaded_file_path}") mime_type = magic.from_file(uploaded_file_path, mime=True) + if mime_type == None: + logger.error(f"uploaded_file_path {uploaded_file_path}") + logger.error(self.driver.page_source) + uploaded_file = Upload.objects.all().order_by("id").last().abstracts_upload.file + mime_type = magic.from_buffer(uploaded_file.read(1024), mime=True) self.assertEqual(mime_type, "text/plain") def test_bz2_pub_med_upload_is_allowable(self):