diff --git a/tests/test_inky.py b/tests/test_inky.py new file mode 100644 index 0000000..b182f97 --- /dev/null +++ b/tests/test_inky.py @@ -0,0 +1,29 @@ +"""Set image tests for Inky.""" +import pytest +import sys + + +@pytest.mark.parametrize('resolution', [(800, 480), (600, 448), (400, 300), (212, 104), (250, 122)]) +def test_inky_set_image(GPIO, spidev, smbus2, resolution): + from inky.inky import Inky + from PIL import Image + import numpy + + phat = Inky(resolution) + + width, height = phat.resolution + + image = Image.new("P", (width, height)) + + for x in range(width): + image.putpixel((x, 0), x % 3) + + assert image.size == (width, height) + + phat.set_image(image) + phat.set_pixel(0, 0, 2) + + data = [x % 3 for x in range(width)] + data[0] = 2 + + assert phat.buf.flatten().tolist()[0:width] == data