update test_path.py to also verify caution.png

This commit is contained in:
mauwii 2023-02-01 00:22:28 +01:00
parent c13e11a264
commit 0009d82a92
No known key found for this signature in database
GPG Key ID: D923DB04ADB3F5AB

View File

@ -1,32 +1,48 @@
import pathlib """
Not really a test, but a way to verify that the paths are existing
and fail early if they are not.
"""
import unittest import unittest
import pathlib
from os import path as osp from os import path as osp
from PIL import Image
import invokeai.configs as configs
import invokeai.frontend.dist as frontend import invokeai.frontend.dist as frontend
import invokeai.configs as configs
import invokeai.assets.web as assets_web
def get_frontend_path() -> pathlib.Path: class ConfigsTestCase(unittest.TestCase):
"""Test the configuration related imports and objects"""
def get_configs_path(self) -> pathlib.Path:
"""Get the path of the configs folder"""
configs_path = pathlib.Path(configs.__path__[0])
return configs_path
def get_frontend_path(self) -> pathlib.Path:
"""Get the path of the frontend dist folder""" """Get the path of the frontend dist folder"""
return pathlib.Path(frontend.__path__[0]) return pathlib.Path(frontend.__path__[0])
def test_configs_path(self):
def get_configs_path() -> pathlib.Path:
"""Get the path of the configs folder"""
return pathlib.Path(configs.__path__[0])
def test_frontend_path():
"""Test that the frontend path is correct"""
TEST_PATH = str(get_frontend_path())
assert TEST_PATH.endswith(osp.join("invokeai", "frontend", "dist"))
def test_configs_path():
"""Test that the configs path is correct""" """Test that the configs path is correct"""
TEST_PATH = str(get_configs_path()) TEST_PATH = str(self.get_configs_path())
assert TEST_PATH.endswith(osp.join("invokeai", "configs")) assert TEST_PATH.endswith(str(osp.join("invokeai", "configs")))
def test_frontend_path(self):
"""Test that the frontend path is correct"""
FRONTEND_PATH = str(self.get_frontend_path())
assert FRONTEND_PATH.endswith(osp.join("invokeai", "frontend", "dist"))
def test_caution_img(self):
"""Verify the caution image"""
caution_img = Image.open(osp.join(assets_web.__path__[0], "caution.png"))
assert caution_img.width == int(500)
assert caution_img.height == int(441)
assert caution_img.format == str("PNG")
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main(
verbosity=2,
)