2023-01-16 22:45:17 +00:00
|
|
|
import pytest
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
from imaginairy.enhancers.blur_detect import is_blurry
|
|
|
|
from tests import TESTS_FOLDER
|
|
|
|
|
|
|
|
blur_params = [
|
|
|
|
(f"{TESTS_FOLDER}/data/black_square.jpg", True),
|
|
|
|
(f"{TESTS_FOLDER}/data/safety.jpg", False),
|
|
|
|
(f"{TESTS_FOLDER}/data/latent_noise.jpg", False),
|
|
|
|
(f"{TESTS_FOLDER}/data/girl_with_a_pearl_earring.jpg", False),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2023-09-29 08:13:50 +00:00
|
|
|
@pytest.mark.parametrize(("img_path", "expected"), blur_params)
|
2023-01-16 22:45:17 +00:00
|
|
|
def test_calculate_blurriness_level(img_path, expected):
|
|
|
|
img = Image.open(img_path)
|
|
|
|
|
|
|
|
assert is_blurry(img) == expected
|