File size: 1,009 Bytes
9bd7d18
 
7af3c8b
3a142aa
9bd7d18
f023709
9bd7d18
 
f023709
 
9bd7d18
f023709
9bd7d18
f023709
9bd7d18
 
 
 
c63c2cd
9bd7d18
 
 
 
 
 
c63c2cd
9bd7d18
 
 
 
 
 
c63c2cd
9bd7d18
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from PIL import Image
import io
import os
from ..app import model

model_instance = model.create_model()


def template(filename: str):
    image = Image.open(filename)
    width, height = image.size
    image_bytes = io.BytesIO()
    image.save(image_bytes, format=image.format)
    output_image = model.run_model(image_bytes, model_instance)
    return width, height, output_image


def test_image_jpg():
    width, height, output_image = template(os.path.join(os.getcwd(), "test/test_images/test1.jpg"))

    assert width == output_image.size[0]
    assert height == output_image.size[1]


def test_image_png():
    width, height, output_image = template(os.path.join(os.getcwd(), "test/test_images/test2.png"))

    assert width == output_image.size[0]
    assert height == output_image.size[1]


def test_image_jpeg():
    width, height, output_image = template(os.path.join(os.getcwd(), "test/test_images/test3.jpeg"))

    assert width == output_image.size[0]
    assert height == output_image.size[1]