Skip to content

Commit

Permalink
add unit test to check mimetype and image resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
anishTP committed Nov 10, 2023
1 parent 81329b2 commit 64d3918
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 0 additions & 1 deletion funnel/views/thumbnails.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from flask import render_template
from html2image import Html2Image

from .. import rq
from ..models import Project, db
from ..signals import project_data_change
from .jobs import rqjob
Expand Down
11 changes: 10 additions & 1 deletion tests/unit/views/preview_image_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import pytest
import io
from PIL import Image

from funnel.views.thumbnails import render_project_preview_image

@pytest.mark.usefixtures('project_expo2011', 'all_fixtures')
def test_preview_image_jobs(project_expo2011):
def test_preview_image_jobs(project_expo2011) -> None:
assert project_expo2011.preview_image is None
render_project_preview_image(project_id=project_expo2011.id)
assert project_expo2011.preview_image is not None

@pytest.mark.usefixtures('project_expo2011', 'all_fixtures')
def test_preview_image_size(project_expo2011) -> None:
render_project_preview_image(project_id=project_expo2011.id)
preview_image = Image.open(io.BytesIO(project_expo2011.preview_image))
assert preview_image.size == (1280, 720)
assert preview_image.format is 'PNG'

0 comments on commit 64d3918

Please sign in to comment.