| 
									
										
										
										
											2022-04-02 01:30:17 +02:00
										 |  |  | #!python3 | 
					
						
							| 
									
										
										
										
											2020-12-05 00:26:13 +01:00
										 |  |  | """
 | 
					
						
							| 
									
										
										
										
											2023-01-11 22:24:39 +01:00
										 |  |  | Inkycal main unittest | 
					
						
							| 
									
										
										
										
											2020-12-05 00:26:13 +01:00
										 |  |  | """
 | 
					
						
							|  |  |  | import os | 
					
						
							| 
									
										
										
										
											2020-11-30 12:09:22 +01:00
										 |  |  | import unittest | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from inkycal import Inkycal | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test_config = """
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     "model": "epd_7_in_5_v3_colour", | 
					
						
							|  |  |  |     "update_interval": 5, | 
					
						
							|  |  |  |     "orientation": 0, | 
					
						
							|  |  |  |     "info_section": true, | 
					
						
							|  |  |  |     "info_section_height": 70, | 
					
						
							|  |  |  |     "calibration_hours": [0, 12, 18], | 
					
						
							|  |  |  |     "modules": [ | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             "position": 1, | 
					
						
							|  |  |  |             "name": "Jokes", | 
					
						
							|  |  |  |             "config": { | 
					
						
							|  |  |  |                 "size": [528, 80], | 
					
						
							|  |  |  |                 "padding_x": 10,"padding_y": 10,"fontsize": 14,"language": "en" | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             "position": 2, | 
					
						
							|  |  |  |             "name": "Calendar", | 
					
						
							|  |  |  |             "config": { | 
					
						
							|  |  |  |                 "size": [528, 343], | 
					
						
							|  |  |  |                 "week_starts_on": "Monday", | 
					
						
							|  |  |  |                 "show_events": true, | 
					
						
							|  |  |  |                 "ical_urls": "https://www.officeholidays.com/ics-fed/usa", | 
					
						
							|  |  |  |                 "ical_files": null, | 
					
						
							|  |  |  |                 "date_format": "D MMM", | 
					
						
							|  |  |  |                 "time_format": "HH:mm", | 
					
						
							|  |  |  |                 "padding_x": 10,"padding_y": 10,"fontsize": 14,"language": "en" | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             "position": 3, | 
					
						
							|  |  |  |             "name": "Feeds", | 
					
						
							|  |  |  |             "config": { | 
					
						
							|  |  |  |                 "size": [528,132], | 
					
						
							|  |  |  |                 "feed_urls": "http://feeds.bbci.co.uk/news/world/rss.xml#", | 
					
						
							|  |  |  |                 "shuffle_feeds": true, | 
					
						
							|  |  |  |                 "padding_x": 10,"padding_y": 10,"fontsize": 14,"language": "en" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     ] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 06:07:14 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class ModuleTest(unittest.TestCase): | 
					
						
							|  |  |  |     @staticmethod | 
					
						
							|  |  |  |     def test_without_rendering(): | 
					
						
							| 
									
										
										
										
											2022-04-14 17:14:30 +02:00
										 |  |  |         # Check if settings.json file exists in current directory | 
					
						
							|  |  |  |         if not os.path.exists("settings.json"): | 
					
						
							|  |  |  |             # Create temporary json settings file with the config from above | 
					
						
							| 
									
										
										
										
											2023-01-11 22:24:39 +01:00
										 |  |  |             with open('settings.json', mode="w", encoding="utf-8") as file: | 
					
						
							| 
									
										
										
										
											2022-04-14 17:14:30 +02:00
										 |  |  |                 file.write(test_config) | 
					
						
							| 
									
										
										
										
											2022-04-14 06:07:14 +02:00
										 |  |  |         print('testing Inkycal in non-render-mode...', end="") | 
					
						
							| 
									
										
										
										
											2023-01-11 22:35:05 +01:00
										 |  |  |         absolute_path_settings_json = os.path.abspath('settings.json') | 
					
						
							|  |  |  |         inky = Inkycal(settings_path=absolute_path_settings_json, render=False) | 
					
						
							| 
									
										
										
										
											2022-04-14 06:07:14 +02:00
										 |  |  |         inky.test() | 
					
						
							|  |  |  |         print('OK') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-30 12:09:22 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							| 
									
										
										
										
											2022-04-14 06:07:14 +02:00
										 |  |  |     unittest.main() |