From 64d3918548bc8c834fe7ef1a1c5c62d861d1db54 Mon Sep 17 00:00:00 2001 From: anishTP Date: Fri, 10 Nov 2023 14:50:58 +0530 Subject: [PATCH] add unit test to check mimetype and image resolution --- funnel/views/thumbnails.py | 1 - tests/unit/views/preview_image_test.py | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/funnel/views/thumbnails.py b/funnel/views/thumbnails.py index 7165648ac..a2ea47b99 100644 --- a/funnel/views/thumbnails.py +++ b/funnel/views/thumbnails.py @@ -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 diff --git a/tests/unit/views/preview_image_test.py b/tests/unit/views/preview_image_test.py index 9ad1c94c2..b037a8f6d 100644 --- a/tests/unit/views/preview_image_test.py +++ b/tests/unit/views/preview_image_test.py @@ -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'