fix tests, add border feature

This commit is contained in:
Ace
2023-11-24 02:37:27 +01:00
parent b08cf00661
commit 60be01fbdb
8 changed files with 60 additions and 32 deletions

View File

@@ -27,7 +27,9 @@ class Config:
# inkycal_todoist_test
TODOIST_API_KEY = get("TODOIST_API_KEY")
TEMP_PATH = f"{basedir}/tmp"
TEMP_PATH = f"{basedir}/temp"
TEST_SETTINGS_PATH = f"{basedir}/settings.json"

View File

@@ -16,8 +16,6 @@ merge = Inkyimage.merge
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
temp_path = f"{Config.TEMP_PATH}/temp.txt"
dummy_data = [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', ' Donec feugiat facilisis neque vel blandit.',
'Integer viverra dolor risus.', ' Etiam neque tellus, sollicitudin at nisi a, mollis ornare enim.',
@@ -56,6 +54,8 @@ dummy_data = [
'Duis facilisis sapien est, a elementum lorem maximus ut.'
]
temp_path = f"{Config.TEMP_PATH}/temp.txt"
tests = [
{
"position": 1,
@@ -74,7 +74,7 @@ tests = [
"name": "TextToFile",
"config": {
"size": [500, 400],
"filepath": "https://de.wikipedia.org/wiki/Nationale_Rotkreuz-_und_Rothalbmond-Gesellschaft",
"filepath": "https://raw.githubusercontent.com/aceinnolab/Inkycal/main/setup.py",
"padding_x": 10,
"padding_y": 10,
"fontsize": 12,
@@ -90,9 +90,8 @@ class TestTextToDisplay(unittest.TestCase):
self.temp_path = temp_path
if not os.path.exists(Config.TEMP_PATH):
os.mkdir(Config.TEMP_PATH)
logger.info("could not find temporary file, creating now.")
with open(self.temp_path, encoding="utf-8", mode="w") as file:
file.writelines(dummy_data)
with open(self.temp_path, encoding="utf-8", mode="w") as file:
file.writelines(dummy_data)
def test_generate_image(self):
for test in tests:

View File

@@ -16,7 +16,7 @@ tests = [
"name": "Webshot",
"config": {
"size": [400, 100],
"url": "https://google.com",
"url": "https://www.catsuthecat.com/blogs/comics/the-one-about-regeneration",
"palette": "bwr",
"padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en"
}
@@ -26,7 +26,7 @@ tests = [
"name": "Webshot",
"config": {
"size": [400, 200],
"url": "https://google.com",
"url": "https://www.catsuthecat.com/blogs/comics/the-one-about-crazy-friday-nights",
"palette": "bwy",
"padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en"
}
@@ -36,7 +36,7 @@ tests = [
"name": "Webshot",
"config": {
"size": [400, 300],
"url": "https://google.com",
"url": "https://www.catsuthecat.com/blogs/comics/the-one-about-teamwork",
"palette": "bw",
"padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en"
}
@@ -46,7 +46,7 @@ tests = [
"name": "Webshot",
"config": {
"size": [400, 400],
"url": "https://google.com",
"url": "https://www.catsuthecat.com/blogs/comics/the-one-about-addictions-1",
"palette": "bwr",
"padding_x": 10, "padding_y": 10, "fontsize": 12, "language": "en"
}

28
tests/test_main.py Normal file
View File

@@ -0,0 +1,28 @@
"""
Test main module
"""
import unittest
from inkycal import Inkycal
from tests import Config
class TestMain(unittest.TestCase):
def setUp(self):
self.settings_path = Config.TEST_SETTINGS_PATH
def test_init(self):
inkycal = Inkycal(self.settings_path, render=False)
assert inkycal.settings["model"] == "image_file"
assert inkycal.settings["update_interval"] == 5
assert inkycal.settings["orientation"] == 0
assert inkycal.settings["info_section"] == True
assert inkycal.settings["info_section_height"] == 70
assert inkycal.settings["border_around_modules"] == True
def test_run(self):
inkycal = Inkycal(self.settings_path, render=False)
inkycal.test()