Skip to content

Commit

Permalink
Update tests to match id3 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Apreche committed Oct 21, 2023
1 parent 390ce26 commit 95e6c94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions media/id3.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def set_id3(

if chapter_image:
image_data = chapter_image.file.read()
# The same image might get used on many chapters, so reset it
chapter_image.file.seek(0)
mime_checker = magic.Magic(mime=True)
image_mime = mime_checker.from_buffer(image_data)
if image_mime in permitted_image_formats:
Expand Down
11 changes: 7 additions & 4 deletions media/tests/test_mp3.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import tempfile
import unittest

from django import test

from frontrowcrew.tests import utils

from media import factories


Expand All @@ -28,7 +28,7 @@ def test_get_xmp_chapters(self):
expected_chapters = [
{
"title": "Marker 01",
"time": 2382,
"start_time": 2382,
}
]
chapters = mp3.get_xmp_chapters()
Expand Down Expand Up @@ -65,6 +65,7 @@ def test_set_id3(self):
self.assertEqual(id3[key].text, value)
self.assertEqual(id3["WOAF"].url, detail_url)

@unittest.skip("album images set from FileFields now")
def test_set_id3_album_image_path(self):
mp3 = factories.MP3Factory()
album_image_path = os.path.join(
Expand All @@ -83,6 +84,7 @@ def test_set_id3_album_image_path(self):
self.assertEqual(apic.mime, "image/png")
self.assertEqual(apic.desc, test_album_image_description)

@unittest.skip("album images set from FileFields now")
def test_set_id3_album_image_fp(self):
mp3 = factories.MP3Factory()
album_image_path = os.path.join(
Expand Down Expand Up @@ -150,6 +152,7 @@ def test_set_id3_advanced_chapters(self):
)
test_chapter_image_description = "test chapter image"
with open(chapter_image_path, "rb") as test_chapter_image_file:
test_file_field = type("",(object,),{"file": test_chapter_image_file})()
test_chapters = [
{
"name": "First Chapter",
Expand All @@ -165,7 +168,7 @@ def test_set_id3_advanced_chapters(self):
"url": "http://frontrowcrew.com/asdf/",
"start_time": 1000,
"end_time": 2000,
"image": test_chapter_image_file,
"image": test_file_field,
"image_description": test_chapter_image_description,
},
{
Expand All @@ -181,7 +184,7 @@ def test_set_id3_advanced_chapters(self):
"description": "Fourth Chapter Description",
"start_time": 5000,
"end_time": 5001,
"image": test_chapter_image_file,
"image": test_file_field,
}
]
mp3 = factories.MP3Factory()
Expand Down

0 comments on commit 95e6c94

Please sign in to comment.