2023-08-09 21:36:47 +03:00
|
|
|
from os import remove
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from PIL.Image import Image
|
|
|
|
|
|
|
|
from huepaper import generate
|
|
|
|
from huepaper.utils import save_image
|
|
|
|
|
|
|
|
|
|
|
|
def test_generation():
|
2023-08-10 15:19:56 +03:00
|
|
|
image = generate()
|
|
|
|
assert isinstance(image, Image)
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
def test_generation_example_6():
|
2023-08-09 21:36:47 +03:00
|
|
|
image = generate(
|
|
|
|
width=500,
|
|
|
|
height=500,
|
|
|
|
)
|
|
|
|
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"))
|