clean code

This commit is contained in:
Chneemann 2024-08-29 17:58:14 +02:00
parent 3f2d4afc06
commit 5cea3b54da
6 changed files with 24 additions and 21 deletions

View file

@ -11,10 +11,10 @@ class VideoTasksTest(TestCase):
Tests whether the HLS conversion script is called correctly and the correct parameters are passed. Tests whether the HLS conversion script is called correctly and the correct parameters are passed.
""" """
mock_subprocess_run.return_value = MagicMock() mock_subprocess_run.return_value = MagicMock()
convert_video_to_hls('test/source.mp4', '1080', 1) convert_video_to_hls('test/source.mp4', '1920x1080', 1)
mock_subprocess_run.assert_called_once() mock_subprocess_run.assert_called_once()
self.assertIn('-i', mock_subprocess_run.call_args[0][0]) self.assertIn('-i', mock_subprocess_run.call_args[0][0])
self.assertIn('hd1080', mock_subprocess_run.call_args[0][0]) self.assertIn('1920x1080', mock_subprocess_run.call_args[0][0])
@patch('os.remove') @patch('os.remove')
def test_delete_original_video(self, mock_os_remove): def test_delete_original_video(self, mock_os_remove):

View file

@ -17,6 +17,7 @@ export class AuthComponent {
authData = { authData = {
mail: '', mail: '',
}; };
constructor( constructor(
private router: Router, private router: Router,
public errorService: ErrorService, public errorService: ErrorService,

View file

@ -1,5 +1,5 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Component } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { BtnLargeComponent } from '../../../shared/components/buttons/btn-large/btn-large.component'; import { BtnLargeComponent } from '../../../shared/components/buttons/btn-large/btn-large.component';
import { FormsModule, NgForm } from '@angular/forms'; import { FormsModule, NgForm } from '@angular/forms';
import { ActivatedRoute, RouterLink } from '@angular/router'; import { ActivatedRoute, RouterLink } from '@angular/router';
@ -13,7 +13,7 @@ import { ErrorService } from '../../../services/error.service';
templateUrl: './forgot-password.component.html', templateUrl: './forgot-password.component.html',
styleUrl: './forgot-password.component.scss', styleUrl: './forgot-password.component.scss',
}) })
export class ForgotPasswordComponent { export class ForgotPasswordComponent implements OnInit {
authData = { authData = {
mail: '', mail: '',
token: '', token: '',

View file

@ -1,4 +1,4 @@
import { Component } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { BtnLargeComponent } from '../../../shared/components/buttons/btn-large/btn-large.component'; import { BtnLargeComponent } from '../../../shared/components/buttons/btn-large/btn-large.component';
import { FormsModule, NgForm } from '@angular/forms'; import { FormsModule, NgForm } from '@angular/forms';
import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { ActivatedRoute, Router, RouterLink } from '@angular/router';
@ -13,7 +13,7 @@ import { ErrorService } from '../../../services/error.service';
templateUrl: './register.component.html', templateUrl: './register.component.html',
styleUrl: './register.component.scss', styleUrl: './register.component.scss',
}) })
export class RegisterComponent { export class RegisterComponent implements OnInit {
authData = { authData = {
mail: '', mail: '',
password: '', password: '',

View file

@ -1,5 +1,6 @@
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { import {
AfterViewInit,
Component, Component,
EventEmitter, EventEmitter,
HostListener, HostListener,
@ -15,7 +16,7 @@ import { environment } from '../../../../environments/environment';
templateUrl: './categories.component.html', templateUrl: './categories.component.html',
styleUrl: './categories.component.scss', styleUrl: './categories.component.scss',
}) })
export class CategoriesComponent { export class CategoriesComponent implements AfterViewInit {
@Input() movies: any[] = []; @Input() movies: any[] = [];
@Input() currentMovie: number = 0; @Input() currentMovie: number = 0;
@Input() favoriteMovies: any[] = []; @Input() favoriteMovies: any[] = [];

View file

@ -4,6 +4,7 @@ import {
ElementRef, ElementRef,
EventEmitter, EventEmitter,
Input, Input,
OnChanges,
Output, Output,
SimpleChanges, SimpleChanges,
} from '@angular/core'; } from '@angular/core';
@ -20,7 +21,7 @@ import { UserService } from '../../../../services/user.service';
templateUrl: './hero-banner.component.html', templateUrl: './hero-banner.component.html',
styleUrl: './hero-banner.component.scss', styleUrl: './hero-banner.component.scss',
}) })
export class HeroBannerComponent { export class HeroBannerComponent implements OnChanges {
@Input() currentMovie: any[] = []; @Input() currentMovie: any[] = [];
@Input() screenWidth: boolean = false; @Input() screenWidth: boolean = false;
@Input() favoriteMovies: any[] = []; @Input() favoriteMovies: any[] = [];
@ -43,19 +44,6 @@ export class HeroBannerComponent {
public userService: UserService public userService: UserService
) {} ) {}
toggleLikeMovie(movieId: number): void {
if (this.favoriteMovies.includes(movieId)) {
this.favoriteMovies = this.favoriteMovies.filter((id) => id !== movieId);
} else {
this.favoriteMovies.push(movieId);
}
this.favoriteMovieChange.emit(this.favoriteMovies);
}
checkLikeMovies(videoId: number) {
return this.favoriteMovies.includes(videoId);
}
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
if (changes['currentMovie'] && this.currentMovie.length > 0) { if (changes['currentMovie'] && this.currentMovie.length > 0) {
const movieId = this.currentMovie[0]?.id; const movieId = this.currentMovie[0]?.id;
@ -70,6 +58,19 @@ export class HeroBannerComponent {
} }
} }
toggleLikeMovie(movieId: number): void {
if (this.favoriteMovies.includes(movieId)) {
this.favoriteMovies = this.favoriteMovies.filter((id) => id !== movieId);
} else {
this.favoriteMovies.push(movieId);
}
this.favoriteMovieChange.emit(this.favoriteMovies);
}
checkLikeMovies(videoId: number) {
return this.favoriteMovies.includes(videoId);
}
isAnyResolutionUploaded(): boolean { isAnyResolutionUploaded(): boolean {
return ( return (
this.movieIsUploaded['320'] || this.movieIsUploaded['320'] ||