fix test
This commit is contained in:
		| @@ -4,75 +4,93 @@ | |||||||
| Slideshow test (inkycal_slideshow) | Slideshow test (inkycal_slideshow) | ||||||
| Copyright by aceisace | Copyright by aceisace | ||||||
| """ | """ | ||||||
|  | import os | ||||||
| import unittest | import unittest | ||||||
|  |  | ||||||
|  | import requests | ||||||
|  | from PIL import Image | ||||||
|  |  | ||||||
| from inkycal.modules import Slideshow as Module | from inkycal.modules import Slideshow as Module | ||||||
| from inkycal.custom import top_level | from inkycal.custom import top_level | ||||||
| from helper_functions import * | from helper_functions import * | ||||||
|  |  | ||||||
| environment = get_environment() | environment = get_environment() | ||||||
|  |  | ||||||
| # Set to True to preview images. Only works on Raspberry Pi OS with Desktop | # Set to True to preview images. Only works on Raspberry Pi OS with Desktop | ||||||
| use_preview = False | use_preview = False | ||||||
|  |  | ||||||
| test_path = f'{top_level}/Gallery' | if not os.path.exists("tmp"): | ||||||
|  |     os.mkdir("tmp") | ||||||
|  |  | ||||||
|  | im_urls = [ | ||||||
|  |     "https://github.com/aceisace/Inkycal/raw/assets/Repo/coffee.png", | ||||||
|  |     "https://github.com/aceisace/Inkycal/raw/assets/Repo/coffee.png" | ||||||
|  | ] | ||||||
|  |  | ||||||
|  | for count, url in enumerate(im_urls): | ||||||
|  |     im = Image.open(requests.get(url, stream=True).raw) | ||||||
|  |     im.save(f"tmp/{count}.png", "PNG") | ||||||
|  |  | ||||||
|  | test_path = "tmp" | ||||||
|  |  | ||||||
|  |  | ||||||
| tests = [ | tests = [ | ||||||
| { |     { | ||||||
|         "name": "Slideshow", |         "name": "Slideshow", | ||||||
|         "config": { |         "config": { | ||||||
|     "size": [400,200], |             "size": [400, 200], | ||||||
|             "path": test_path, |             "path": test_path, | ||||||
|             "palette": "bwy", |             "palette": "bwy", | ||||||
|             "autoflip": True, |             "autoflip": True, | ||||||
|             "orientation": "vertical", |             "orientation": "vertical", | ||||||
|             "padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en" |             "padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en" | ||||||
|         } |         } | ||||||
| }, |     }, | ||||||
| { |     { | ||||||
|         "name": "Slideshow", |         "name": "Slideshow", | ||||||
|         "config": { |         "config": { | ||||||
|     "size": [800,500], |             "size": [800, 500], | ||||||
|             "path": test_path, |             "path": test_path, | ||||||
|             "palette": "bw", |             "palette": "bw", | ||||||
|             "autoflip": True, |             "autoflip": True, | ||||||
|             "orientation": "vertical", |             "orientation": "vertical", | ||||||
|             "padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en" |             "padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en" | ||||||
|         } |         } | ||||||
| }, |     }, | ||||||
| { |     { | ||||||
|         "name": "Slideshow", |         "name": "Slideshow", | ||||||
|         "config": { |         "config": { | ||||||
|     "size": [400,100], |             "size": [400, 100], | ||||||
|             "path": test_path, |             "path": test_path, | ||||||
|             "palette": "bwr", |             "palette": "bwr", | ||||||
|             "autoflip": False, |             "autoflip": False, | ||||||
|             "orientation": "vertical", |             "orientation": "vertical", | ||||||
|             "padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en" |             "padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en" | ||||||
|         } |         } | ||||||
| }, |     }, | ||||||
| { |     { | ||||||
|         "name": "Slideshow", |         "name": "Slideshow", | ||||||
|         "config": { |         "config": { | ||||||
|     "size": [400,100], |             "size": [400, 100], | ||||||
|             "path": test_path, |             "path": test_path, | ||||||
|             "palette": "bwy", |             "palette": "bwy", | ||||||
|             "autoflip": True, |             "autoflip": True, | ||||||
|             "orientation": "vertical", |             "orientation": "vertical", | ||||||
|             "padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en" |             "padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en" | ||||||
|         } |         } | ||||||
| }, |     }, | ||||||
| { |     { | ||||||
|         "name": "Slideshow", |         "name": "Slideshow", | ||||||
|         "config": { |         "config": { | ||||||
|     "size": [400,100], |             "size": [400, 100], | ||||||
|             "path": test_path, |             "path": test_path, | ||||||
|             "palette": "bwy", |             "palette": "bwy", | ||||||
|             "autoflip": True, |             "autoflip": True, | ||||||
|             "orientation": "horizontal", |             "orientation": "horizontal", | ||||||
|             "padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en" |             "padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en" | ||||||
|         } |         } | ||||||
| }, |     }, | ||||||
| { |     { | ||||||
|         "name": "Slideshow", |         "name": "Slideshow", | ||||||
|         "config": { |         "config": { | ||||||
|             "size": [500, 800], |             "size": [500, 800], | ||||||
| @@ -82,8 +100,8 @@ tests = [ | |||||||
|             "orientation": "vertical", |             "orientation": "vertical", | ||||||
|             "padding_x": 0, "padding_y": 0, "fontsize": 12, "language": "en" |             "padding_x": 0, "padding_y": 0, "fontsize": 12, "language": "en" | ||||||
|         } |         } | ||||||
| }, |     }, | ||||||
| { |     { | ||||||
|         "position": 1, |         "position": 1, | ||||||
|         "name": "Slideshow", |         "name": "Slideshow", | ||||||
|         "config": { |         "config": { | ||||||
| @@ -94,18 +112,19 @@ tests = [ | |||||||
|             "orientation": "vertical", |             "orientation": "vertical", | ||||||
|             "padding_x": 20, "padding_y": 20, "fontsize": 12, "language": "en" |             "padding_x": 20, "padding_y": 20, "fontsize": 12, "language": "en" | ||||||
|         } |         } | ||||||
| }, |     }, | ||||||
| ] | ] | ||||||
|  |  | ||||||
|  |  | ||||||
| class module_test(unittest.TestCase): | class module_test(unittest.TestCase): | ||||||
|     def test_get_config(self): |     def test_get_config(self): | ||||||
|     print('getting data for web-ui...', end = "") |         print('getting data for web-ui...', end="") | ||||||
|         Module.get_config() |         Module.get_config() | ||||||
|         print('OK') |         print('OK') | ||||||
|  |  | ||||||
|     def test_generate_image(self): |     def test_generate_image(self): | ||||||
|         for test in tests: |         for test in tests: | ||||||
|       print(f'test {tests.index(test)+1} generating image..') |             print(f'test {tests.index(test) + 1} generating image..') | ||||||
|             module = Module(test) |             module = Module(test) | ||||||
|             im_black, im_colour = module.generate_image() |             im_black, im_colour = module.generate_image() | ||||||
|             print('OK') |             print('OK') | ||||||
| @@ -129,8 +148,8 @@ class module_test(unittest.TestCase): | |||||||
|  |  | ||||||
|         print('OK') |         print('OK') | ||||||
|  |  | ||||||
| if __name__ == '__main__': |  | ||||||
|  |  | ||||||
|  | if __name__ == '__main__': | ||||||
|     logger = logging.getLogger() |     logger = logging.getLogger() | ||||||
|     logger.level = logging.DEBUG |     logger.level = logging.DEBUG | ||||||
|     logger.addHandler(logging.StreamHandler(sys.stdout)) |     logger.addHandler(logging.StreamHandler(sys.stdout)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user