def setUp(self): user = User.objects.create(username="******", password="******") # owner1 = Owner.objects.get(user__username="******") video = Video.objects.create( title="Video1", owner=user, video="test.mp4", type=Type.objects.get(id=1), ) tempfile = NamedTemporaryFile(delete=True) video.video.save("test.mp4", tempfile) dest = os.path.join(settings.MEDIA_ROOT, video.video.name) shutil.copyfile(VIDEO_TEST, dest) print("\n ---> Start Encoding video") encode.encode_video(video.id) print("\n ---> End Encoding video") audio = Video.objects.create( title="Audio1", owner=user, video="test.mp3", type=Type.objects.get(id=1), ) tempfile = NamedTemporaryFile(delete=True) audio.video.save("test.mp3", tempfile) dest = os.path.join(settings.MEDIA_ROOT, audio.video.name) shutil.copyfile(AUDIO_TEST, dest) print("\n ---> Start Encoding audio") encode.encode_video(audio.id) print("\n ---> End Encoding audio") print(" ---> SetUp of EncodeTestCase : OK !")
def task_start_encode(self, video_id): print("CELERY START ENCODE VIDEO ID %s" % video_id) from pod.video.encode import encode_video encode_video(video_id)