Move everything to one file
This commit is contained in:
@ -1,36 +1,26 @@
|
||||
import imghdr
|
||||
import os
|
||||
|
||||
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
|
||||
from discord_embed import settings
|
||||
from discord_embed.main import (
|
||||
app,
|
||||
generate_html_for_videos,
|
||||
make_thumbnail,
|
||||
send_webhook,
|
||||
video_resolution,
|
||||
)
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
client = TestClient(app)
|
||||
TEST_FILE = "tests/test.mp4"
|
||||
|
||||
|
||||
def test_version():
|
||||
"""Test that version is correct."""
|
||||
assert __version__ == "1.0.0"
|
||||
|
||||
|
||||
def test_domain_ends_with_slash():
|
||||
"""Test that domain ends with slash."""
|
||||
assert not settings.serve_domain.endswith("/")
|
||||
|
||||
|
||||
def test_generate_html_for_videos():
|
||||
"""Test that generate_html_for_videos() works."""
|
||||
# TODO: We should probably import this from settings.py instead of
|
||||
# hardcoding it here. If we change it in settings.py, it won't be
|
||||
# changed here.
|
||||
|
||||
domain = os.environ["SERVE_DOMAIN"]
|
||||
|
||||
# Remove trailing slash from domain
|
||||
if domain.endswith("/"):
|
||||
domain = domain[:-1]
|
||||
|
||||
@ -45,47 +35,26 @@ def test_generate_html_for_videos():
|
||||
|
||||
|
||||
def test_video_resolution():
|
||||
"""Test that video_resolution() works."""
|
||||
assert video_resolution(TEST_FILE) == (422, 422)
|
||||
resolution = video_resolution(TEST_FILE)
|
||||
assert resolution.width == 422
|
||||
assert resolution.height == 422
|
||||
|
||||
|
||||
def test_make_thumbnail():
|
||||
"""Test that make_thumbnail() works."""
|
||||
# TODO: We should probably import this from settings.py instead of
|
||||
# hardcoding it here. If we change it in settings.py, it won't be
|
||||
# changed here.
|
||||
|
||||
domain = os.environ["SERVE_DOMAIN"]
|
||||
|
||||
# Remove trailing slash from domain
|
||||
if domain.endswith("/"):
|
||||
domain = domain[:-1]
|
||||
|
||||
thumbnail = make_thumbnail(TEST_FILE, "test.mp4")
|
||||
# Check that thumbnail is a jpeg.
|
||||
assert imghdr.what(f"{settings.upload_folder}/test.mp4.jpg") == "jpeg"
|
||||
|
||||
# Check that the it returns the correct URL.
|
||||
assert thumbnail == f"{domain}/test.mp4.jpg"
|
||||
|
||||
|
||||
def test_save_to_disk():
|
||||
"""Test that save_to_disk() works."""
|
||||
# TODO: Implement this test. I need to mock the UploadFile object.
|
||||
|
||||
|
||||
def test_do_things():
|
||||
"""Test that do_things() works."""
|
||||
# TODO: Implement this test. I need to mock the UploadFile object.
|
||||
|
||||
|
||||
def test_send_webhook():
|
||||
"""Test that send_webhook() works."""
|
||||
send_webhook("Running Pytest")
|
||||
|
||||
|
||||
def test_main():
|
||||
"""Test that main() works."""
|
||||
data_without_trailing_nl = ""
|
||||
response = client.get("/")
|
||||
|
||||
@ -102,14 +71,7 @@ def test_main():
|
||||
|
||||
|
||||
def test_upload_file():
|
||||
"""Test if we can upload files."""
|
||||
# TODO: We should probably import this from settings.py instead of
|
||||
# hardcoding it here. If we change it in settings.py, it won't be
|
||||
# changed here.
|
||||
|
||||
domain = os.environ["SERVE_DOMAIN"]
|
||||
|
||||
# Remove trailing slash from domain
|
||||
if domain.endswith("/"):
|
||||
domain = domain[:-1]
|
||||
|
||||
|
Reference in New Issue
Block a user