41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from comfy_client import ComfyClient, _format_api_error
|
|
|
|
|
|
def test_format_node_errors() -> None:
|
|
message = _format_api_error(
|
|
{
|
|
"error": {"message": "Prompt outputs failed validation"},
|
|
"node_errors": {
|
|
"20": {
|
|
"errors": [
|
|
{"message": "Required input is missing", "details": "image"}
|
|
]
|
|
}
|
|
},
|
|
}
|
|
)
|
|
assert "Prompt outputs failed validation" in message
|
|
assert "узел 20" in message
|
|
assert "image" in message
|
|
|
|
|
|
def test_find_output_image() -> None:
|
|
entry = {
|
|
"outputs": {
|
|
"9": {
|
|
"images": [
|
|
{"filename": "result.png", "subfolder": "", "type": "output"}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
image = ComfyClient.find_output_image(None, entry) # type: ignore[arg-type]
|
|
assert image is not None
|
|
assert image["filename"] == "result.png"
|
|
|
|
|
|
def test_find_output_image_empty() -> None:
|
|
assert ComfyClient.find_output_image(None, {}) is None # type: ignore[arg-type]
|