def test_sources_unknown_type(self): fake_file = ContentFile(b("A boring example movie")) fake_file.name = 'movie' media = models.Media() media.file = File(fake_file) self.assertEqual(media.sources, [{ 'src': '/media/movie', 'type': 'application/octet-stream', }])
def test_sources_mp4_type(self): fake_file = ContentFile(b("A boring example movie")) fake_file.name = 'movie.mp4' media = models.Media() media.file = File(fake_file) self.assertEqual(media.sources, [{ 'src': '/media/movie.mp4', 'type': 'video/mp4', }])
def make_media(): fake_file = ContentFile(b("A boring example song")) fake_file.name = 'song.mp3' for i in range(50): media = models.Media( title="Test " + str(i), duration=100 + i, file=fake_file, type='audio', ) media.save()
def setUp(self): self.media = models.Media(title="Test media", duration=100) self.media.file.save('example.mp4', ContentFile("A amazing example music video")) self.extensionless_media = models.Media(title="Test media", duration=101) self.extensionless_media.file.save('example', ContentFile("A boring example music video"))