Inkycal/tests/test_inkycal_webshot.py

75 lines
1.9 KiB
Python
Raw Permalink Normal View History

2023-11-21 20:16:10 +01:00
"""
Test Inkycal Webshot Module
"""
import logging
import unittest
from inkycal.modules import Webshot
2024-05-11 23:25:40 +02:00
from inkycal.modules.inky_image import Inkyimage
from tests import Config
2023-11-21 20:16:10 +01:00
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
2024-05-11 23:25:40 +02:00
preview = Inkyimage.preview
merge = Inkyimage.merge
2023-11-21 20:16:10 +01:00
tests = [
{
"position": 1,
"name": "Webshot",
"config": {
2024-06-20 22:31:17 +02:00
"size": [400, 200],
"url": "https://aceinnolab.com",
2023-11-21 20:16:10 +01:00
"palette": "bwr",
"padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en"
}
},
{
"position": 1,
"name": "Webshot",
"config": {
2024-06-20 22:31:17 +02:00
"size": [400, 400],
"url": "https://aceinnolab.com",
2023-11-21 20:16:10 +01:00
"palette": "bwy",
2024-06-20 22:31:17 +02:00
"rotation": 0,
2023-11-21 20:16:10 +01:00
"padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en"
}
},
{
"position": 1,
"name": "Webshot",
"config": {
2024-06-20 22:31:17 +02:00
"size": [400, 600],
"url": "https://aceinnolab.com",
2023-11-21 20:16:10 +01:00
"palette": "bw",
2024-06-20 22:31:17 +02:00
"rotation": 90,
2023-11-21 20:16:10 +01:00
"padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en"
}
},
{
"position": 1,
"name": "Webshot",
"config": {
2024-06-20 22:31:17 +02:00
"size": [400, 800],
"url": "https://aceinnolab.com",
2023-11-21 20:16:10 +01:00
"palette": "bwr",
2024-06-20 22:31:17 +02:00
"rotation": 180,
2023-11-21 20:16:10 +01:00
"padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en"
}
}
]
class TestWebshot(unittest.TestCase):
def test_generate_image(self):
for test in tests:
logger.info(f'test {tests.index(test) + 1} generating image..')
module = Webshot(test)
2024-05-11 23:25:40 +02:00
im_black, im_colour = module.generate_image()
if Config.USE_PREVIEW:
preview(merge(im_black, im_colour))
2023-11-21 20:16:10 +01:00
logger.info('OK')