huepaper/tests/test_generator.py
profitroll 70d0279cb9
All checks were successful
Tests / test (3.10) (push) Successful in 1m10s
Tests / test (3.11) (push) Successful in 1m9s
Tests / test (3.8) (push) Successful in 1m13s
Tests / test (3.9) (push) Successful in 1m12s
Fixed -p and improved coverage
2023-08-10 14:31:33 +02:00

85 lines
1.8 KiB
Python

from os import remove
from pathlib import Path
from subprocess import run
from PIL.Image import Image
from huepaper import generate
from huepaper.utils import save_image
def test_generation():
image = generate()
assert isinstance(image, Image)
def test_saving():
image = generate(
500,
500,
hue_max=1.0,
lum_min=0.3,
lum_max=0.6,
sat_min=0.8,
sat_max=1.0,
lines=0.0,
)
save_image(image, Path("tests/image.jpg"))
assert Path("tests/image.jpg").exists()
remove(Path("tests/image.jpg"))
def test_shell():
assert (
run(
[
"huepaper",
"-hue",
"0.3",
"-lmin",
"0.5",
"-lmax",
"0.3",
"-l",
"0.5",
"-p",
"64x36",
"-o",
"tests/image.jpg",
],
check=False,
).returncode
== 0
)
remove(Path("tests/image.jpg"))
def test_generation_example_1():
image = generate(color="lightgreen")
assert isinstance(image, Image)
def test_generation_example_2():
image = generate(color="#ff7f50", lines_bright=0.05)
assert isinstance(image, Image)
def test_generation_example_3():
image = generate(hue_max=1.0, lum_min=0.3, lum_max=0.6, sat_min=0.8, sat_max=1.0)
assert isinstance(image, Image)
def test_generation_example_4():
image = generate(hue_max=0.3, lum_min=0.5, lum_max=0.5, lines=0.5, pixelate="64x36")
assert isinstance(image, Image)
def test_generation_example_5():
image = generate(
lines=0.3,
lines_bright=0.1,
lines_dark=0.1,
emblem=Path("tests/assets/emblem.png"),
)
assert isinstance(image, Image)