Improved testing algorithm
Generalized code logic for testing. Added support for several test configs at once.
This commit is contained in:
		| @@ -1,12 +1,14 @@ | |||||||
| import unittest | import unittest | ||||||
| from inkycal.modules import Agenda as Module | from inkycal.modules import Agenda as Module | ||||||
|  |  | ||||||
| test = { | tests = [ | ||||||
|  | { | ||||||
|   "position": 1, |   "position": 1, | ||||||
|   "name": "Agenda", |   "name": "Agenda", | ||||||
|   "config": { |   "config": { | ||||||
|     "size": [880,100], |     "size": [880,100], | ||||||
|       "ical_urls": "https://www.officeholidays.com/ics-fed/usa",                "ical_files": "", |       "ical_urls": "https://www.officeholidays.com/ics-fed/usa", | ||||||
|  |       "ical_files": None, | ||||||
|       "date_format": "ddd D MMM", |       "date_format": "ddd D MMM", | ||||||
|       "time_format": "HH:mm", |       "time_format": "HH:mm", | ||||||
|       "padding_x": 10, |       "padding_x": 10, | ||||||
| @@ -14,19 +16,22 @@ test = { | |||||||
|       "fontsize": 12, |       "fontsize": 12, | ||||||
|       "language": "en" |       "language": "en" | ||||||
|   } |   } | ||||||
| } | }, | ||||||
|  | ] | ||||||
|  |  | ||||||
|  |  | ||||||
| module = Module(test) |  | ||||||
|    |  | ||||||
| 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') |     print('getting data for web-ui...', end = "") | ||||||
|     module.get_config() |     Module.get_config() | ||||||
|  |     print('OK') | ||||||
|  |  | ||||||
|   def test_generate_image(self): |   def test_generate_image(self): | ||||||
|     print('testing image generation') |     for test in tests: | ||||||
|     module.generate_image() |       print(f'test {tests.index(test)+1} generating image..') | ||||||
|  |       module = Module(test) | ||||||
|  |       module.generate_image() | ||||||
|  |       print('OK') | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|   unittest.main() |   unittest.main() | ||||||
|   | |||||||
| @@ -1,15 +1,16 @@ | |||||||
| import unittest | import unittest | ||||||
| from inkycal.modules import Calendar as Module | from inkycal.modules import Calendar as Module | ||||||
|  |  | ||||||
| test = { | tests = [ | ||||||
|  | { | ||||||
|   "position": 2, |   "position": 2, | ||||||
|   "name": "Calendar", |   "name": "Calendar", | ||||||
|   "config": { |   "config": { | ||||||
|     "size": [880,343], |     "size": [800, 400], | ||||||
|     "week_starts_on": "Monday", |     "week_starts_on": "Monday", | ||||||
|     "show_events": "True", |     "show_events": True, | ||||||
|     "ical_urls": "https://www.officeholidays.com/ics-fed/usa", |     "ical_urls": "https://www.officeholidays.com/ics-fed/usa", | ||||||
|     "ical_files": "", |     "ical_files": None, | ||||||
|     "date_format": "D MMM", |     "date_format": "D MMM", | ||||||
|     "time_format": "HH:mm", |     "time_format": "HH:mm", | ||||||
|     "padding_x": 10, |     "padding_x": 10, | ||||||
| @@ -17,18 +18,72 @@ test = { | |||||||
|     "fontsize": 12, |     "fontsize": 12, | ||||||
|     "language": "en" |     "language": "en" | ||||||
|     } |     } | ||||||
| } | }, | ||||||
|  | { | ||||||
| module = Module(test) |   "position": 2, | ||||||
|  |   "name": "Calendar", | ||||||
|  |   "config": { | ||||||
|  |     "size": [800, 400], | ||||||
|  |     "week_starts_on": "Sunday", | ||||||
|  |     "show_events": True, | ||||||
|  |     "ical_urls": "https://www.officeholidays.com/ics-fed/usa", | ||||||
|  |     "ical_files": None, | ||||||
|  |     "date_format": "D MMM", | ||||||
|  |     "time_format": "HH:mm", | ||||||
|  |     "padding_x": 10, | ||||||
|  |     "padding_y": 10, | ||||||
|  |     "fontsize": 12, | ||||||
|  |     "language": "en" | ||||||
|  |     } | ||||||
|  | }, | ||||||
|  | { | ||||||
|  |   "position": 2, | ||||||
|  |   "name": "Calendar", | ||||||
|  |   "config": { | ||||||
|  |     "size": [800, 400], | ||||||
|  |     "week_starts_on": "Monday", | ||||||
|  |     "show_events": False, | ||||||
|  |     "ical_urls": "https://www.officeholidays.com/ics-fed/usa", | ||||||
|  |     "ical_files": None, | ||||||
|  |     "date_format": "D MMM", | ||||||
|  |     "time_format": "HH:mm", | ||||||
|  |     "padding_x": 10, | ||||||
|  |     "padding_y": 10, | ||||||
|  |     "fontsize": 12, | ||||||
|  |     "language": "en" | ||||||
|  |     } | ||||||
|  | }, | ||||||
|  | { | ||||||
|  |   "position": 2, | ||||||
|  |   "name": "Calendar", | ||||||
|  |   "config": { | ||||||
|  |     "size": [800, 400], | ||||||
|  |     "week_starts_on": "Monday", | ||||||
|  |     "show_events": True, | ||||||
|  |     "ical_urls": None, | ||||||
|  |     "ical_files": None, | ||||||
|  |     "date_format": "D MMM", | ||||||
|  |     "time_format": "HH:mm", | ||||||
|  |     "padding_x": 10, | ||||||
|  |     "padding_y": 10, | ||||||
|  |     "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') |     print('getting data for web-ui...', end = "") | ||||||
|     module.get_config() |     Module.get_config() | ||||||
|  |     print('OK') | ||||||
|  |  | ||||||
|   def test_generate_image(self): |   def test_generate_image(self): | ||||||
|     print('testing image generation') |     for test in tests: | ||||||
|     module.generate_image() |       print(f'test {tests.index(test)+1} generating image..', end="") | ||||||
|  |       module = Module(test) | ||||||
|  |       module.generate_image() | ||||||
|  |       print('OK') | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|   unittest.main() |   unittest.main() | ||||||
|   | |||||||
| @@ -1,30 +1,47 @@ | |||||||
| import unittest | import unittest | ||||||
| from inkycal.modules import Feeds as Module | from inkycal.modules import Feeds as Module | ||||||
|  |  | ||||||
| test = { | tests = [ | ||||||
|  | { | ||||||
|   "position": 1, |   "position": 1, | ||||||
|   "name": "Feeds", |   "name": "Feeds", | ||||||
|   "config": { |   "config": { | ||||||
|     "size": [400,100], |     "size": [400,100], | ||||||
|     "feed_urls": "http://feeds.bbci.co.uk/news/world/rss.xml#", |     "feed_urls": "http://feeds.bbci.co.uk/news/world/rss.xml#", | ||||||
|     "shuffle_feeds": "True", |     "shuffle_feeds": True, | ||||||
|     "padding_x": 10, |     "padding_x": 10, | ||||||
|     "padding_y": 10, |     "padding_y": 10, | ||||||
|     "fontsize": 12, |     "fontsize": 12, | ||||||
|     "language": "en" |     "language": "en" | ||||||
|     } |     } | ||||||
| } | }, | ||||||
|  | { | ||||||
| module = Module(test) |   "position": 1, | ||||||
|  |   "name": "Feeds", | ||||||
|  |   "config": { | ||||||
|  |     "size": [400,100], | ||||||
|  |     "feed_urls": "http://feeds.bbci.co.uk/news/world/rss.xml#", | ||||||
|  |     "shuffle_feeds": False, | ||||||
|  |     "padding_x": 10, | ||||||
|  |     "padding_y": 10, | ||||||
|  |     "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') |     print('getting data for web-ui...', end = "") | ||||||
|     module.get_config() |     Module.get_config() | ||||||
|  |     print('OK') | ||||||
|  |  | ||||||
|   def test_generate_image(self): |   def test_generate_image(self): | ||||||
|     print('testing image generation') |     for test in tests: | ||||||
|     module.generate_image() |       print(f'test {tests.index(test)+1} generating image..') | ||||||
|  |       module = Module(test) | ||||||
|  |       module.generate_image() | ||||||
|  |       print('OK') | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|   unittest.main() |   unittest.main() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user