async def test_build(app, needs_build, needs_launch, always_build, slug, pytestconfig):
    """
    Test build a repo that is very quick and easy to build.
    """
    # can't use mark.github_api since only some tests here use GitHub
    if slug.startswith("gh/") and "not github_api" in pytestconfig.getoption(
        "markexpr"
    ):
        pytest.skip("Skipping GitHub API test")
    build_url = f"{app.url}/build/{slug}"
    r = await async_requests.get(build_url, stream=True)
    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']}")
            # this is the signal that everything is ready, pod is launched
            # and server is up inside the pod. Break out of the loop now
            # because BinderHub keeps the connection open for many seconds
            # after to avoid "reconnects" from slow clients
            if event.get("phase") == "ready":
                r.close()
                break
            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"
    assert "url" in final
    assert "token" in final
    print(final["url"])
    r = await async_requests.get(url_concat(final["url"], {"token": final["token"]}))
    r.raise_for_status()
    assert r.url.startswith(final["url"])

    # stop the server
    stop = await async_requests.post(
        url_concat(f"{final['url']}api/shutdown", {"token": final["token"]})
    )
    stop.raise_for_status()

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