Improved testing algorithm

Generalized code logic for testing. Added support for several test configs at once.
This commit is contained in:
Ace 2020-11-12 10:14:57 +01:00
parent c358cf5b3b
commit e866a04e0e
3 changed files with 108 additions and 31 deletions

View File

@ -1,12 +1,14 @@
import unittest
from inkycal.modules import Agenda as Module
test = {
tests = [
{
"position": 1,
"name": "Agenda",
"config": {
"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",
"time_format": "HH:mm",
"padding_x": 10,
@ -14,19 +16,22 @@ test = {
"fontsize": 12,
"language": "en"
}
}
},
]
module = Module(test)
class module_test(unittest.TestCase):
def test_get_config(self):
print('getting data for web-ui')
module.get_config()
print('getting data for web-ui...', end = "")
Module.get_config()
print('OK')
def test_generate_image(self):
print('testing image generation')
module.generate_image()
for test in tests:
print(f'test {tests.index(test)+1} generating image..')
module = Module(test)
module.generate_image()
print('OK')
if __name__ == '__main__':
unittest.main()

View File

@ -1,15 +1,16 @@
import unittest
from inkycal.modules import Calendar as Module
test = {
tests = [
{
"position": 2,
"name": "Calendar",
"config": {
"size": [880,343],
"size": [800, 400],
"week_starts_on": "Monday",
"show_events": "True",
"show_events": True,
"ical_urls": "https://www.officeholidays.com/ics-fed/usa",
"ical_files": "",
"ical_files": None,
"date_format": "D MMM",
"time_format": "HH:mm",
"padding_x": 10,
@ -17,18 +18,72 @@ test = {
"fontsize": 12,
"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):
def test_get_config(self):
print('getting data for web-ui')
module.get_config()
print('getting data for web-ui...', end = "")
Module.get_config()
print('OK')
def test_generate_image(self):
print('testing image generation')
module.generate_image()
for test in tests:
print(f'test {tests.index(test)+1} generating image..', end="")
module = Module(test)
module.generate_image()
print('OK')
if __name__ == '__main__':
unittest.main()

View File

@ -1,30 +1,47 @@
import unittest
from inkycal.modules import Feeds as Module
test = {
tests = [
{
"position": 1,
"name": "Feeds",
"config": {
"size": [400,100],
"feed_urls": "http://feeds.bbci.co.uk/news/world/rss.xml#",
"shuffle_feeds": "True",
"shuffle_feeds": True,
"padding_x": 10,
"padding_y": 10,
"fontsize": 12,
"language": "en"
}
}
},
{
"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"
}
},
]
module = Module(test)
class module_test(unittest.TestCase):
def test_get_config(self):
print('getting data for web-ui')
module.get_config()
print('getting data for web-ui...', end = "")
Module.get_config()
print('OK')
def test_generate_image(self):
print('testing image generation')
module.generate_image()
for test in tests:
print(f'test {tests.index(test)+1} generating image..')
module = Module(test)
module.generate_image()
print('OK')
if __name__ == '__main__':
unittest.main()