mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
refactor(model_scanner): normalize path comparisons for model roots
fix(example_images_download_manager): re-raise specific exception on download error refactor(usage_stats): define constants locally to avoid conditional imports test(example_images_download_manager): update exception handling in download tests test(example_images_file_manager): differentiate between os.startfile and subprocess.Popen in tests test(example_images_paths): ensure valid example images root with single-library mode test(usage_stats): use string literals for metadata payload to avoid conditional imports
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from typing import Any, Dict
|
||||
|
||||
@@ -37,20 +38,30 @@ async def test_open_folder_requires_existing_model_directory(monkeypatch: pytest
|
||||
(model_folder / "image.png").write_text("data", encoding="utf-8")
|
||||
|
||||
popen_calls: list[list[str]] = []
|
||||
startfile_calls: list[str] = []
|
||||
|
||||
class DummyPopen:
|
||||
def __init__(self, cmd, *_args, **_kwargs):
|
||||
popen_calls.append(cmd)
|
||||
|
||||
def dummy_startfile(path):
|
||||
startfile_calls.append(path)
|
||||
|
||||
monkeypatch.setattr("subprocess.Popen", DummyPopen)
|
||||
monkeypatch.setattr("os.startfile", dummy_startfile)
|
||||
|
||||
request = JsonRequest({"model_hash": model_hash})
|
||||
response = await ExampleImagesFileManager.open_folder(request)
|
||||
body = json.loads(response.text)
|
||||
|
||||
assert body["success"] is True
|
||||
assert popen_calls
|
||||
assert model_hash in popen_calls[0][-1]
|
||||
# On Windows, os.startfile is used; on other platforms, subprocess.Popen
|
||||
if os.name == 'nt':
|
||||
assert startfile_calls
|
||||
assert model_hash in startfile_calls[0]
|
||||
else:
|
||||
assert popen_calls
|
||||
assert model_hash in popen_calls[0][-1]
|
||||
|
||||
|
||||
async def test_open_folder_rejects_invalid_paths(monkeypatch: pytest.MonkeyPatch, tmp_path) -> None:
|
||||
|
||||
Reference in New Issue
Block a user