2023-01-31 23:22:28 +00:00
|
|
|
"""
|
|
|
|
Not really a test, but a way to verify that the paths are existing
|
|
|
|
and fail early if they are not.
|
|
|
|
"""
|
2023-01-31 08:06:06 +00:00
|
|
|
import unittest
|
2023-01-31 23:22:28 +00:00
|
|
|
import pathlib
|
2023-01-31 08:06:06 +00:00
|
|
|
from os import path as osp
|
2023-01-31 23:22:28 +00:00
|
|
|
from PIL import Image
|
2023-01-31 08:06:06 +00:00
|
|
|
|
2023-01-31 17:18:32 +00:00
|
|
|
import invokeai.frontend.dist as frontend
|
2023-01-31 23:22:28 +00:00
|
|
|
import invokeai.configs as configs
|
|
|
|
import invokeai.assets.web as assets_web
|
2023-01-31 08:06:06 +00:00
|
|
|
|
|
|
|
|
2023-01-31 23:22:28 +00:00
|
|
|
class ConfigsTestCase(unittest.TestCase):
|
|
|
|
"""Test the configuration related imports and objects"""
|
2023-01-31 08:06:06 +00:00
|
|
|
|
2023-01-31 23:22:28 +00:00
|
|
|
def get_configs_path(self) -> pathlib.Path:
|
|
|
|
"""Get the path of the configs folder"""
|
|
|
|
configs_path = pathlib.Path(configs.__path__[0])
|
|
|
|
return configs_path
|
2023-01-31 08:06:06 +00:00
|
|
|
|
2023-01-31 23:22:28 +00:00
|
|
|
def get_frontend_path(self) -> pathlib.Path:
|
|
|
|
"""Get the path of the frontend dist folder"""
|
|
|
|
return pathlib.Path(frontend.__path__[0])
|
2023-01-31 08:06:06 +00:00
|
|
|
|
2023-01-31 23:22:28 +00:00
|
|
|
def test_configs_path(self):
|
|
|
|
"""Test that the configs path is correct"""
|
|
|
|
TEST_PATH = str(self.get_configs_path())
|
|
|
|
assert TEST_PATH.endswith(str(osp.join("invokeai", "configs")))
|
2023-01-31 08:06:06 +00:00
|
|
|
|
2023-01-31 23:22:28 +00:00
|
|
|
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"))
|
2023-01-31 08:06:06 +00:00
|
|
|
|
2023-01-31 23:22:28 +00:00
|
|
|
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")
|
2023-01-31 08:06:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-01-31 23:22:28 +00:00
|
|
|
unittest.main(
|
|
|
|
verbosity=2,
|
|
|
|
)
|