Skip to content

Commit

Permalink
Fixing downloader unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
deepaerial committed Jun 13, 2023
1 parent 6c34664 commit 79fc76f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
17 changes: 5 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from datetime import datetime, timedelta
import random
from datetime import datetime
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Generator, Iterable, Optional
Expand All @@ -21,7 +22,7 @@
"url": "https://www.youtube.com/watch?v=NcBjx_eyvxc",
"title": "Madeira | Cinematic FPV",
"duration": 224,
"thumbnailUrl": "https://i.ytimg.com/vi/NcBjx_eyvxc/sddefault.jpg",
"thumbnailUrl": "https://i.ytimg.com/vi/NcBjx_eyvxc/hq720.jpg?sqp=-oaymwEXCNUGEOADIAQqCwjVARCqCBh4INgESFo&rs=AOn4CLBaSe3Sk63UjfwWlEhviOSxrq6TEg",
"audioStreams": [
{"id": "251", "mimetype": "audio/webm", "bitrate": "160kbps"},
{"id": "250", "mimetype": "audio/webm", "bitrate": "70kbps"},
Expand All @@ -30,27 +31,19 @@
{"id": "139", "mimetype": "audio/mp4", "bitrate": "48kbps"},
],
"videoStreams": [
{"id": "394", "mimetype": "video/mp4", "resolution": "144p"},
{"id": "278", "mimetype": "video/webm", "resolution": "144p"},
{"id": "160", "mimetype": "video/mp4", "resolution": "144p"},
{"id": "395", "mimetype": "video/mp4", "resolution": "240p"},
{"id": "242", "mimetype": "video/webm", "resolution": "240p"},
{"id": "133", "mimetype": "video/mp4", "resolution": "240p"},
{"id": "396", "mimetype": "video/mp4", "resolution": "360p"},
{"id": "243", "mimetype": "video/webm", "resolution": "360p"},
{"id": "134", "mimetype": "video/mp4", "resolution": "360p"},
{"id": "397", "mimetype": "video/mp4", "resolution": "480p"},
{"id": "244", "mimetype": "video/webm", "resolution": "480p"},
{"id": "135", "mimetype": "video/mp4", "resolution": "480p"},
{"id": "398", "mimetype": "video/mp4", "resolution": "720p"},
{"id": "247", "mimetype": "video/webm", "resolution": "720p"},
{"id": "136", "mimetype": "video/mp4", "resolution": "720p"},
{"id": "399", "mimetype": "video/mp4", "resolution": "1080p"},
{"id": "248", "mimetype": "video/webm", "resolution": "1080p"},
{"id": "137", "mimetype": "video/mp4", "resolution": "1080p"},
{"id": "400", "mimetype": "video/mp4", "resolution": "1440p"},
{"id": "271", "mimetype": "video/webm", "resolution": "1440p"},
{"id": "401", "mimetype": "video/mp4", "resolution": "2160p"},
{"id": "313", "mimetype": "video/webm", "resolution": "2160p"},
],
"mediaFormats": ["mp4", "mp3", "wav"],
Expand Down Expand Up @@ -150,8 +143,8 @@ def app_client(settings: Settings):
def mock_download_params() -> DownloadParams:
return DownloadParams(
url=EXAMPLE_VIDEO_PREVIEW["url"], # type: ignore
video_stream_id=EXAMPLE_VIDEO_PREVIEW["videoStreams"][12]["id"], # type: ignore
audio_stream_id=EXAMPLE_VIDEO_PREVIEW["audioStreams"][0]["id"], # type: ignore
video_stream_id=random.choice(EXAMPLE_VIDEO_PREVIEW["videoStreams"])["id"], # type: ignore
audio_stream_id=random.choice(EXAMPLE_VIDEO_PREVIEW["audioStreams"])["id"], # type: ignore
media_format=MediaFormat.MP4,
)

Expand Down
4 changes: 2 additions & 2 deletions tests/downloaders/test_pytube_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_video_download(
Test video download.
"""
mock_persisted_download.audio_stream_id = "251"
mock_persisted_download.video_stream_id = "394"
mock_persisted_download.video_stream_id = "278"
assert mock_persisted_download.status == DownloadStatus.STARTED
assert mock_persisted_download.file_path is None
assert mock_persisted_download.when_started_download is None
Expand All @@ -45,6 +45,6 @@ def test_video_download(
assert isinstance(finished_download.when_download_finished, datetime)
assert finished_download.file_path is not None
assert finished_download.audio_stream_id == "251"
assert finished_download.video_stream_id == "394"
assert finished_download.video_stream_id == "278"
downloaded_file_bytes = local_storage.get_download(finished_download.file_path)
assert isinstance(downloaded_file_bytes, bytes)

0 comments on commit 79fc76f

Please sign in to comment.