2020-12-05 00:16:07 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
Calendar test (inkycal_calendar)
|
|
|
|
Copyright by aceisace
|
|
|
|
"""
|
|
|
|
|
2020-06-10 15:12:44 +02:00
|
|
|
import unittest
|
2020-11-10 22:48:04 +01:00
|
|
|
from inkycal.modules import Calendar as Module
|
2020-12-05 00:16:07 +01:00
|
|
|
from helper_functions import *
|
|
|
|
environment = get_environment()
|
|
|
|
|
|
|
|
# Set to True to preview images. Only works on Raspberry Pi OS with Desktop
|
|
|
|
use_preview = False
|
|
|
|
|
|
|
|
|
|
|
|
sample_url = "https://www.officeholidays.com/ics-fed/usa"
|
2020-06-10 15:12:44 +02:00
|
|
|
|
2020-11-12 10:14:57 +01:00
|
|
|
tests = [
|
|
|
|
{
|
2020-11-10 22:48:04 +01:00
|
|
|
"name": "Calendar",
|
|
|
|
"config": {
|
2020-12-05 00:16:07 +01:00
|
|
|
"size": [500, 500],
|
2020-11-10 22:48:04 +01:00
|
|
|
"week_starts_on": "Monday",
|
2020-11-12 10:14:57 +01:00
|
|
|
"show_events": True,
|
2020-12-05 00:16:07 +01:00
|
|
|
"ical_urls": sample_url,
|
2020-11-12 10:14:57 +01:00
|
|
|
"ical_files": None,
|
2020-12-05 00:16:07 +01:00
|
|
|
"date_format": "D MMM", "time_format": "HH:mm",
|
2020-11-30 12:08:56 +01:00
|
|
|
"padding_x": 10,"padding_y": 10,"fontsize": 12,"language": "en"
|
2020-11-10 22:48:04 +01:00
|
|
|
}
|
2020-11-12 10:14:57 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Calendar",
|
|
|
|
"config": {
|
2020-11-24 00:39:23 +01:00
|
|
|
"size": [400, 800],
|
2020-11-12 10:14:57 +01:00
|
|
|
"week_starts_on": "Sunday",
|
|
|
|
"show_events": True,
|
2020-12-05 00:16:07 +01:00
|
|
|
"ical_urls": sample_url,
|
2020-11-12 10:14:57 +01:00
|
|
|
"ical_files": None,
|
2020-12-05 00:16:07 +01:00
|
|
|
"date_format": "D MMM", "time_format": "HH:mm",
|
2020-11-30 12:08:56 +01:00
|
|
|
"padding_x": 10,"padding_y": 10,"fontsize": 12,"language": "en"
|
2020-11-12 10:14:57 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Calendar",
|
|
|
|
"config": {
|
2020-11-24 00:39:23 +01:00
|
|
|
"size": [400, 800],
|
2020-11-12 10:14:57 +01:00
|
|
|
"week_starts_on": "Monday",
|
|
|
|
"show_events": False,
|
2020-12-05 00:16:07 +01:00
|
|
|
"ical_urls": sample_url,
|
2020-11-12 10:14:57 +01:00
|
|
|
"ical_files": None,
|
2020-12-05 00:16:07 +01:00
|
|
|
"date_format": "D MMM", "time_format": "HH:mm",
|
2020-11-30 12:08:56 +01:00
|
|
|
"padding_x": 10,"padding_y": 10,"fontsize": 12,"language": "en"
|
2020-11-12 10:14:57 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Calendar",
|
|
|
|
"config": {
|
2020-11-24 00:39:23 +01:00
|
|
|
"size": [400, 800],
|
2020-11-12 10:14:57 +01:00
|
|
|
"week_starts_on": "Monday",
|
|
|
|
"show_events": True,
|
|
|
|
"ical_urls": None,
|
|
|
|
"ical_files": None,
|
2020-12-05 00:16:07 +01:00
|
|
|
"date_format": "D MMM", "time_format": "HH:mm",
|
2020-11-30 12:08:56 +01:00
|
|
|
"padding_x": 10,"padding_y": 10,"fontsize": 12,"language": "en"
|
2020-11-12 10:14:57 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
2020-11-10 22:48:04 +01:00
|
|
|
|
|
|
|
class module_test(unittest.TestCase):
|
|
|
|
def test_get_config(self):
|
2020-11-12 10:14:57 +01:00
|
|
|
print('getting data for web-ui...', end = "")
|
|
|
|
Module.get_config()
|
|
|
|
print('OK')
|
2020-06-10 15:12:44 +02:00
|
|
|
|
|
|
|
def test_generate_image(self):
|
2020-11-12 10:14:57 +01:00
|
|
|
for test in tests:
|
|
|
|
print(f'test {tests.index(test)+1} generating image..', end="")
|
|
|
|
module = Module(test)
|
2020-12-05 00:16:07 +01:00
|
|
|
im_black, im_colour = module.generate_image()
|
2020-11-12 10:14:57 +01:00
|
|
|
print('OK')
|
2020-12-05 00:16:07 +01:00
|
|
|
if use_preview == True and environment == 'Raspberry':
|
|
|
|
preview(merge(im_black, im_colour))
|
2020-06-10 15:12:44 +02:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-12-05 00:16:07 +01:00
|
|
|
|
|
|
|
logger = logging.getLogger()
|
|
|
|
logger.level = logging.DEBUG
|
|
|
|
logger.addHandler(logging.StreamHandler(sys.stdout))
|
|
|
|
|
2020-06-10 15:12:44 +02:00
|
|
|
unittest.main()
|