From fd318d182ed06650f27042105befb0a6a0dfeb87 Mon Sep 17 00:00:00 2001 From: Georgiana Dolocan Date: Fri, 7 Apr 2023 15:41:27 +0300 Subject: [PATCH] Update initial test --- binderhub/tests/test_build.py | 42 +++++++---------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/binderhub/tests/test_build.py b/binderhub/tests/test_build.py index f9b6ae6f3..40b4802f6 100644 --- a/binderhub/tests/test_build.py +++ b/binderhub/tests/test_build.py @@ -12,6 +12,7 @@ from kubernetes import client from tornado.httputil import url_concat from tornado.queues import Queue +from tornado.web import HTTPError from binderhub.build import KubernetesBuildExecutor, ProgressEvent from binderhub.build_local import LocalRepo2dockerBuild, ProcessTerminated, _execute_cmd @@ -124,45 +125,18 @@ async def test_build_fail(app, needs_build, needs_launch, always_build, pytestco @pytest.mark.remote async def test_build_no_launch(app): """ - Test build endpoint with no launch option active, passed as a request query param. + Test build endpoint with build_only launch option active, + passed as a request query param, + but `require_build_only = False`. """ slug = "gh/binderhub-ci-repos/cached-minimal-dockerfile/HEAD" build_url = f"{app.url}/build/{slug}" params = {} - params = {"no-launch": "True"} + params = {"build_only": "true"} r = await async_requests.get(build_url, stream=True, params=params) - 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") == "info": - assert ( - "Found no launch option. Image will not be launched after build" - in event["message"] - ) - # This is the signal that the image was built. - # Check the message for clue that the image won't be launched and - # 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": - assert "Image won't be launched" in event["message"] - r.close() - break - if event.get("phase") == "launching": - launch_events += 1 - - assert launch_events == 0 - final = events[-1] - assert "phase" in final - assert final["phase"] == "ready" - + with pytest.raises(HTTPError): + r.raise_for_status() + assert r.reason == "Building but not launching is not permitted!" def _list_image_builder_pods_mock(): """Mock list of DIND pods"""