Move test_make_thumbnail() and test_video_resolution() to own file

This commit is contained in:
2022-08-06 16:48:32 +02:00
parent fcad955db6
commit 14c2d74c46
3 changed files with 33 additions and 23 deletions

View File

@ -1,4 +1,3 @@
import imghdr
import os
from fastapi.testclient import TestClient
@ -6,7 +5,6 @@ from fastapi.testclient import TestClient
from discord_embed import __version__, settings
from discord_embed.generate_html import generate_html_for_videos
from discord_embed.main import app
from discord_embed.video import make_thumbnail, video_resolution
from discord_embed.webhook import send_webhook
client = TestClient(app)
@ -41,27 +39,6 @@ def test_generate_html_for_videos():
assert generated_html == f"{domain}/test_video.mp4"
def test_video_resolution():
"""Test video_resolution() works."""
assert video_resolution(TEST_FILE) == (422, 422)
def test_make_thumbnail():
"""Test make_thumbnail() works."""
domain = os.environ["SERVE_DOMAIN"]
# Remove trailing slash from domain
if domain.endswith("/"):
domain = domain[:-1]
thumbnail = make_thumbnail(TEST_FILE, "test.mp4")
# Check if thumbnail is a jpeg.
assert imghdr.what(f"{settings.upload_folder}/test.mp4.jpg") == "jpeg"
# Check if it returns the correct URL.
assert thumbnail == f"{domain}/test.mp4.jpg"
def test_save_to_disk():
"""Test save_to_disk() works."""
# TODO: Implement this test. I need to mock the UploadFile object.