Skip to content

Commit

Permalink
Test that pdf and png can be created
Browse files Browse the repository at this point in the history
  • Loading branch information
fcooper8472 committed Aug 22, 2024
1 parent 1be5462 commit 83dca3e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dev = ["pytest>=7.0"]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
addopts = "-ra -vvv --log-cli-level=INFO"
testpaths = [
"tests",
]
Expand Down
8 changes: 7 additions & 1 deletion src/videotoolkit/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
from reportlab.pdfgen import canvas
from .utils import add_logo, generate_hex_grid

from pathlib import Path
import logging

def create_start_slide(filename: str, title: str, subtitle: str):
logger = logging.getLogger(__name__)


def create_start_slide(filename: str | Path, title: str, subtitle: str):
"""Creates a PDF start slide with the given title and subtitle."""
# Define the dimensions for a 16:9 aspect ratio
width, height = 3840, 2160
Expand All @@ -28,6 +33,7 @@ def create_start_slide(filename: str, title: str, subtitle: str):
# Save PDF
c.showPage()
c.save()
logger.info(f'Saved {filename}')


def create_end_slide(filename: str, message: str):
Expand Down
19 changes: 17 additions & 2 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@
# This source code is licensed under the MIT License found in the
# LICENSE file in the root directory of this source tree.

from pathlib import Path
import tempfile

import videotoolkit


def test_create_start_slide():
"""Placeholder test for create_start_slide"""
assert True # Replace with real test later
with tempfile.TemporaryDirectory() as temp_dir:
# Convert the temporary directory path to a Path object
temp_path = Path(temp_dir)

pdf_file = temp_path / 'test.pdf'
png_file = temp_path / 'test.png'

videotoolkit.create_start_slide(str(pdf_file), 'title', 'subtitle')
videotoolkit.pdf_to_png(temp_path / 'test.pdf')

assert pdf_file.is_file()
assert png_file.is_file()


def test_create_end_slide():
Expand Down

0 comments on commit 83dca3e

Please sign in to comment.