def test_process_audio_file(self): audio = Audio.objects.get(pk=1) audio.duration = None audio.save() audio = Audio.objects.get(pk=1) self.assertNotEqual(audio.duration, 15) process_audio_file(pk=1) audio = Audio.objects.get(pk=1) self.assertEqual(audio.duration, 15)
def test_process_audio_file(self): audio = Audio.objects.get(pk=1) audio.duration = None audio.save() audio = Audio.objects.get(pk=1) self.assertNotEqual(audio.duration, 15, msg='we start with a fake duration in the fixture') process_audio_file(pk=1) audio = Audio.objects.get(pk=1) self.assertEqual(audio.duration, 15, msg='we should end up with the proper duration')
def test_process_audio_file(self): audio = Audio.objects.get(pk=1) audio.duration = None audio.save() audio = Audio.objects.get(pk=1) self.assertNotEqual(audio.duration, 15, msg='we start with a fake duration in the fixture') process_audio_file(pk=1) audio = Audio.objects.get(pk=1) correct_duration = 15 measured_duration = audio.duration # Use almost equal because measuring MP3's is wonky. self.assertAlmostEqual( measured_duration, correct_duration, delta=5, msg='We should end up with the proper duration of about %s. ' 'Instead we got %s.' % (correct_duration, measured_duration))
def test_process_audio_file(self): audio = Audio.objects.get(pk=1) audio.duration = None audio.save() audio = Audio.objects.get(pk=1) self.assertNotEqual(audio.duration, 15, msg='we start with a fake duration in the fixture') process_audio_file(pk=1) audio = Audio.objects.get(pk=1) correct_duration = 15 measured_duration = audio.duration # Use almost equal because measuring MP3's is wonky. self.assertAlmostEqual( measured_duration, correct_duration, delta=5, msg='We should end up with the proper duration of about %s. ' 'Instead we got %s.' % (correct_duration, measured_duration) )
def test_process_audio_file(self): af = Audio.objects.get(pk=1) af.duration = None af.save() expected_duration = 15 self.assertNotEqual( af.duration, expected_duration, msg="Do we have no duration info at the outset?", ) process_audio_file(pk=1) af.refresh_from_db() measured_duration = af.duration # Use almost equal because measuring MP3's is wonky. self.assertAlmostEqual( measured_duration, expected_duration, delta=5, msg="We should end up with the proper duration of about %s. " "Instead we got %s." % (expected_duration, measured_duration), )