import worker


def test_dispatch_routes_to_provider(monkeypatch):
    called = {}
    monkeypatch.setattr(worker, "run_gpt_image_generation", lambda tid, p: called.setdefault("gpt", (tid, p)))
    worker._dispatch({"job_type": "gpt_image_generation", "task_id": "t1", "params": {"prompt": "x"}})
    assert called["gpt"][0] == "t1"


def test_dispatch_unknown_job_type_reports_failed(monkeypatch):
    calls = []
    monkeypatch.setattr(worker, "webhook_update_task", lambda *a, **k: calls.append((a, k)))
    worker._dispatch({"job_type": "midjourney_generation", "task_id": "t9", "params": {}})
    assert calls[-1][0][1] == "failed"
