import nas_client


def test_webhook_includes_image_url(monkeypatch):
    captured = {}

    def fake_post(payload):
        captured.update(payload)

    monkeypatch.setattr(nas_client, "_post", fake_post)
    nas_client.webhook_update_task("t1", "succeeded", 100, "done", image_url="/media/image/t1.png")
    assert captured["task_id"] == "t1"
    assert captured["image_url"] == "/media/image/t1.png"


def test_webhook_omits_none_fields(monkeypatch):
    captured = {}
    monkeypatch.setattr(nas_client, "_post", lambda p: captured.update(p))
    nas_client.webhook_update_task("t2", "processing", 10, "working")
    assert "image_url" not in captured and "error" not in captured
