async def test_build_only(app, build_only_query_param, needs_build):
    """
    Test build a repo that is very quick and easy to build.
    """
    slug = "gh/binderhub-ci-repos/cached-minimal-dockerfile/HEAD"
    build_url = f"{app.url}/build/{slug}"
    r = await async_requests.get(
        build_url, stream=True, params={"build_only": build_only_query_param}
    )
    r.raise_for_status()
    events = []
    launch_events = 0
    async for line in async_requests.iter_lines(r):
        line = line.decode("utf8", "replace")
        if line.startswith("data:"):
            event = json.loads(line.split(":", 1)[1])
            events.append(event)
            assert "message" in event
            sys.stdout.write(f"{event.get('phase', '')}: {event['message']}")
            if event.get("phase") == "ready":
                r.close()
                break
            if event.get("phase") == "info":
                assert (
                    "The built image will not be launched because the API only mode was enabled and the query parameter `build_only` was set to true"
                    in event["message"]
                )
            if event.get("phase") == "launching" and not event["message"].startswith(
                ("Launching server...", "Launch attempt ")
            ):
                # skip standard launching events of builder
                # we are interested in launching events from spawner
                launch_events += 1

    assert launch_events == 0
    final = events[-1]
    assert "phase" in final
    assert final["phase"] == "ready"

    Test build a repo that is very quick and easy to build.
    
binderhub/tests/test_build.py