Fixed -p and improved coverage
This commit is contained in:
84
tests/test_generator.py
Normal file
84
tests/test_generator.py
Normal file
@@ -0,0 +1,84 @@
|
||||
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)
|
Reference in New Issue
Block a user