added video convert test & bugfixes
This commit is contained in:
parent
62cec4c82d
commit
7c25827096
5 changed files with 28 additions and 9 deletions
|
|
@ -18,7 +18,7 @@ def video_post_save(sender, instance, created, **kwargs):
|
||||||
create_thumbnails(instance, instance.id)
|
create_thumbnails(instance, instance.id)
|
||||||
|
|
||||||
#Convert video
|
#Convert video
|
||||||
for resolution in ["480", "720", "1080"]:
|
for resolution in ["720", "480", "1080"]:
|
||||||
queue.enqueue(convert_video_to_hls, instance.video_file.path, resolution, instance.id)
|
queue.enqueue(convert_video_to_hls, instance.video_file.path, resolution, instance.id)
|
||||||
|
|
||||||
#Delete the original video file
|
#Delete the original video file
|
||||||
|
|
|
||||||
|
|
@ -62,4 +62,5 @@ def create_thumbnails(instance, model_id):
|
||||||
ffmpeg.input(video_file_path, ss=1).output(thumbnail_480_path, vf='scale=720:-1', vframes=1).run(overwrite_output=True)
|
ffmpeg.input(video_file_path, ss=1).output(thumbnail_480_path, vf='scale=720:-1', vframes=1).run(overwrite_output=True)
|
||||||
|
|
||||||
except ffmpeg._run.Error as e:
|
except ffmpeg._run.Error as e:
|
||||||
print(f"Ein Fehler ist aufgetreten: {e.stderr.decode()}")
|
error_message = e.stderr.decode() if e.stderr else "Unknown ffmpeg error"
|
||||||
|
print(f"Ein Fehler ist aufgetreten: {error_message}")
|
||||||
|
|
@ -1,3 +1,21 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from unittest.mock import patch, MagicMock
|
||||||
|
from .tasks import convert_video_to_hls, delete_original_video, create_thumbnails
|
||||||
|
from .signals import auto_delete_file_on_delete
|
||||||
|
from .models import Video
|
||||||
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||||
|
|
||||||
# Create your tests here.
|
|
||||||
|
class VideoTasksTest(TestCase):
|
||||||
|
@patch('subprocess.run')
|
||||||
|
def test_convert_video_to_hls(self, mock_subprocess_run):
|
||||||
|
mock_subprocess_run.return_value = MagicMock()
|
||||||
|
convert_video_to_hls('test/source.mp4', '1080', 1)
|
||||||
|
mock_subprocess_run.assert_called_once()
|
||||||
|
self.assertIn('-i', mock_subprocess_run.call_args[0][0])
|
||||||
|
self.assertIn('hd1080', mock_subprocess_run.call_args[0][0])
|
||||||
|
|
||||||
|
@patch('os.remove')
|
||||||
|
def test_delete_original_video(self, mock_os_remove):
|
||||||
|
delete_original_video('test/source.mp4')
|
||||||
|
mock_os_remove.assert_called_once_with('test/source.mp4')
|
||||||
|
|
@ -36,9 +36,9 @@ urlpatterns = [
|
||||||
path('django-rq/', include('django_rq.urls')),
|
path('django-rq/', include('django_rq.urls')),
|
||||||
|
|
||||||
# Content URLs
|
# Content URLs
|
||||||
path('content/', content_views.video_list),
|
path('content/', content_views.video_list, name='video_list'),
|
||||||
path('content/upload/', content_views.video_upload),
|
path('content/upload/', content_views.video_upload, name='video_upload'),
|
||||||
path('content/movie/<int:id>/', content_views.check_video),
|
path('content/movie/<int:id>/', content_views.check_video, name='check_video'),
|
||||||
|
|
||||||
# Users URLs
|
# Users URLs
|
||||||
path('users/', user_views.user_list, name='user_list'),
|
path('users/', user_views.user_list, name='user_list'),
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,10 @@ export class AuthService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async login(body: any, storage: boolean) {
|
async login(body: any, storage: boolean) {
|
||||||
const data = await lastValueFrom(
|
const data = (await lastValueFrom(
|
||||||
this.http.post(`${environment.baseUrl}/auth/login/`, body)
|
this.http.post(`${environment.baseUrl}/auth/login/`, body)
|
||||||
);
|
)) as { token: string };
|
||||||
this.storeAuthToken(data, storage);
|
this.storeAuthToken(data.token, storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
async verifyEmail(body: any) {
|
async verifyEmail(body: any) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue