25 lines
978 B
Python
25 lines
978 B
Python
from pixellab import PixelLabClient
|
|
|
|
|
|
def test_image_sources_reads_completed_job_images():
|
|
response = {
|
|
"last_response": {
|
|
"images": [{"base64": "data:image/png;base64,AAAA"}],
|
|
"url": "https://example.com/preview.png",
|
|
}
|
|
}
|
|
assert PixelLabClient.image_sources(response) == [
|
|
"data:image/png;base64,AAAA",
|
|
"https://example.com/preview.png",
|
|
]
|
|
|
|
|
|
def test_create_image_uses_style_endpoint(monkeypatch):
|
|
client = PixelLabClient(api_key="test")
|
|
monkeypatch.setattr(client, "_reference", lambda _: {"image": {"base64": "x"}, "width": 64, "height": 64})
|
|
captured = {}
|
|
monkeypatch.setattr(client, "_request", lambda method, path, payload: captured.update(method=method, path=path, payload=payload) or {})
|
|
client.create_image("ship", 64, 64, reference_images=["style.png"])
|
|
assert captured["path"] == "/generate-with-style-v2"
|
|
assert captured["payload"]["style_images"][0]["width"] == 64
|