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
This commit is contained in:
parent
af8da71c9a
commit
5ee3d1efdd
1 changed files with 12 additions and 2 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue