diff --git a/comfy/component_model/folder_path_types.py b/comfy/component_model/folder_path_types.py index 91aec66e2..56486bc8b 100644 --- a/comfy/component_model/folder_path_types.py +++ b/comfy/component_model/folder_path_types.py @@ -102,7 +102,7 @@ class PathsList: paths = [x for x in self] return paths[item] - def append(self, path_str: str): + def append(self, path_str: str | Path): p: FolderNames = self.parent() p.add_paths(self.folder_name, [path_str]) diff --git a/tests/unit/app_test/model_manager_test.py b/tests/unit/app_test/model_manager_test.py index f25bbf6e8..fe7d4114c 100644 --- a/tests/unit/app_test/model_manager_test.py +++ b/tests/unit/app_test/model_manager_test.py @@ -1,22 +1,26 @@ -import pytest import base64 import json import struct from io import BytesIO + +import pytest from PIL import Image from aiohttp import web -from unittest.mock import patch from comfy.app.model_manager import ModelFileManager +from comfy.component_model.folder_path_types import FolderNames +from comfy.execution_context import context_folder_names_and_paths pytestmark = ( pytest.mark.asyncio ) # This applies the asyncio mark to all test functions in the module + @pytest.fixture def model_manager(): return ModelFileManager() + @pytest.fixture def app(model_manager): app = web.Application() @@ -25,6 +29,7 @@ def app(model_manager): app.add_routes(routes) return app + async def test_get_model_preview_safetensors(aiohttp_client, app, tmp_path): img = Image.new('RGB', (100, 100), 'white') img_byte_arr = BytesIO() @@ -43,9 +48,12 @@ async def test_get_model_preview_safetensors(aiohttp_client, app, tmp_path): f.write(length_bytes) f.write(header_bytes) - with patch('folder_paths.folder_names_and_paths', { - 'test_folder': ([str(tmp_path)], None) - }): + fn = FolderNames() + with context_folder_names_and_paths(fn): + test_folder = fn["test_folder"] + test_folder.paths.append(tmp_path) + test_folder.supported_extensions |= {".safetensors"} + client = await aiohttp_client(app) response = await client.get('/experiment/models/preview/test_folder/0/test_model.safetensors')