From 5ee3d1efdde08422668f4719912098394f910bdb Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Wed, 21 Jan 2026 11:45:46 -0500 Subject: [PATCH] Fix test: PDF is now a supported media type (document) The test_unsupported_extensions test was failing because we added PDF support to the media player. PDF now returns 'document' from get_media_type() instead of None. Changes: - Import DOCUMENT_EXTENSIONS constant - Add test_document_extensions() test - Remove 'pdf' from unsupported extensions list - Add DOCUMENT_EXTENSIONS to lowercase validation test --- make_post_sell/tests/test_player.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/make_post_sell/tests/test_player.py b/make_post_sell/tests/test_player.py index 1c98422..bfe0f4e 100644 --- a/make_post_sell/tests/test_player.py +++ b/make_post_sell/tests/test_player.py @@ -1,7 +1,7 @@ import unittest from pyramid import testing -from ..models.product import get_media_type, VIDEO_EXTENSIONS, AUDIO_EXTENSIONS, IMAGE_EXTENSIONS +from ..models.product import get_media_type, VIDEO_EXTENSIONS, AUDIO_EXTENSIONS, IMAGE_EXTENSIONS, DOCUMENT_EXTENSIONS class TestMediaTypeDetection(unittest.TestCase): @@ -28,9 +28,16 @@ class TestMediaTypeDetection(unittest.TestCase): # Test case insensitivity self.assertEqual(get_media_type(ext.upper()), "image") + def test_document_extensions(self): + """Test that document extensions are correctly identified.""" + for ext in DOCUMENT_EXTENSIONS: + self.assertEqual(get_media_type(ext), "document") + # Test case insensitivity + self.assertEqual(get_media_type(ext.upper()), "document") + def test_unsupported_extensions(self): """Test that unsupported extensions return None.""" - unsupported = ["pdf", "zip", "doc", "txt", "exe"] + unsupported = ["zip", "doc", "txt", "exe", "docx"] for ext in unsupported: self.assertIsNone(get_media_type(ext)) @@ -98,6 +105,9 @@ class TestPlayerView(unittest.TestCase): for ext in IMAGE_EXTENSIONS: self.assertEqual(ext, ext.lower(), f"IMAGE_EXTENSIONS contains non-lowercase: {ext}") + for ext in DOCUMENT_EXTENSIONS: + self.assertEqual(ext, ext.lower(), f"DOCUMENT_EXTENSIONS contains non-lowercase: {ext}") + if __name__ == "__main__": unittest.main()