2828
2929from .conftest import (
3030 API_ID ,
31+ API_ORIGIN ,
3132 APP ,
32- BROKER ,
3333 ENDPOINT_ID ,
3434 INDEX ,
3535 LIVE_ITEMS ,
@@ -520,8 +520,8 @@ def test_base_url_is_overridable() -> None:
520520
521521@respx .mock
522522def test_runs_get_and_abort (cw : CleanedWeb ) -> None :
523- respx .get (f"{ BROKER } /v1/runs/{ RUN_ID } " ).mock (return_value = httpx .Response (200 , json = run_object ()))
524- abort = respx .post (f"{ BROKER } /v1/runs/{ RUN_ID } /abort" ).mock (
523+ respx .get (f"{ API_ORIGIN } /v1/runs/{ RUN_ID } " ).mock (return_value = httpx .Response (200 , json = run_object ()))
524+ abort = respx .post (f"{ API_ORIGIN } /v1/runs/{ RUN_ID } /abort" ).mock (
525525 return_value = httpx .Response (202 , json = {** run_object (), "abort_requested" : True })
526526 )
527527 run = cw .runs .get (RUN_ID )
@@ -537,7 +537,7 @@ def test_runs_items_follows_cursor_pages(cw: CleanedWeb) -> None:
537537 "2" : {"items" : [{"n" : 3 }], "count" : 1 , "next_cursor" : 3 , "run_status" : "finished" },
538538 "3" : {"items" : [], "count" : 0 , "next_cursor" : None , "run_status" : "finished" },
539539 }
540- route = respx .get (f"{ BROKER } /v1/runs/{ RUN_ID } /items" ).mock (
540+ route = respx .get (f"{ API_ORIGIN } /v1/runs/{ RUN_ID } /items" ).mock (
541541 side_effect = lambda request : httpx .Response (200 , json = pages [request .url .params ["cursor" ]])
542542 )
543543 assert [i ["n" ] for i in cw .runs .items (RUN_ID , limit = 2 )] == [1 , 2 , 3 ]
@@ -552,7 +552,7 @@ def test_runs_items_stops_on_empty_page_unless_following(cw: CleanedWeb, sleeps:
552552 {"items" : [{"n" : 2 }], "next_cursor" : 2 , "run_status" : "running" },
553553 {"items" : [], "next_cursor" : None , "run_status" : "finished" },
554554 ]
555- route = respx .get (f"{ BROKER } /v1/runs/{ RUN_ID } /items" ).mock (
555+ route = respx .get (f"{ API_ORIGIN } /v1/runs/{ RUN_ID } /items" ).mock (
556556 side_effect = [httpx .Response (200 , json = r ) for r in responses ]
557557 )
558558 assert [i ["n" ] for i in cw .runs .items (RUN_ID )] == [1 ]
@@ -563,7 +563,7 @@ def test_runs_items_stops_on_empty_page_unless_following(cw: CleanedWeb, sleeps:
563563
564564@respx .mock
565565def test_runs_result_waits_for_the_end (cw : CleanedWeb , sleeps : List [float ]) -> None :
566- respx .get (f"{ BROKER } /v1/runs/{ RUN_ID } /result" ).mock (
566+ respx .get (f"{ API_ORIGIN } /v1/runs/{ RUN_ID } /result" ).mock (
567567 side_effect = [
568568 httpx .Response (202 , json = run_object (), headers = {"Retry-After" : "5" }),
569569 httpx .Response (200 , json = final_body ()),
@@ -575,7 +575,9 @@ def test_runs_result_waits_for_the_end(cw: CleanedWeb, sleeps: List[float]) -> N
575575
576576@respx .mock
577577def test_runs_result_wait_false_returns_the_running_run (cw : CleanedWeb ) -> None :
578- respx .get (f"{ BROKER } /v1/runs/{ RUN_ID } /result" ).mock (return_value = httpx .Response (202 , json = run_object ()))
578+ respx .get (f"{ API_ORIGIN } /v1/runs/{ RUN_ID } /result" ).mock (
579+ return_value = httpx .Response (202 , json = run_object ())
580+ )
579581 result = cw .runs .result (RUN_ID , wait = False )
580582 assert not result .complete and result .run ["status" ] == "running"
581583
@@ -589,7 +591,7 @@ def pages(request: httpx.Request) -> httpx.Response:
589591 200 , json = {"runs" : [{** run_object ("failed" ), "run_id" : "b" * 32 }], "next_cursor" : None }
590592 )
591593
592- route = respx .get (f"{ BROKER } /v1/runs" ).mock (side_effect = pages )
594+ route = respx .get (f"{ API_ORIGIN } /v1/runs" ).mock (side_effect = pages )
593595 page = cw .runs .list (source_id = "src" , status = "finished" , limit = 10 )
594596 assert page .next_cursor == "c2" and page .runs [0 ].status == "finished"
595597 assert dict (route .calls [0 ].request .url .params ) == {
@@ -605,10 +607,10 @@ def pages(request: httpx.Request) -> httpx.Response:
605607
606608@respx .mock
607609def test_sources_run_200_and_202 (cw : CleanedWeb , sleeps : List [float ]) -> None :
608- post = respx .post (f"{ BROKER } /v1/sources/src_1/run" ).mock (
610+ post = respx .post (f"{ API_ORIGIN } /v1/sources/src_1/run" ).mock (
609611 side_effect = [httpx .Response (200 , json = final_body ()), httpx .Response (202 , json = run_object ())]
610612 )
611- result_route = respx .get (f"{ BROKER } /v1/runs/{ RUN_ID } /result" ).mock (
613+ result_route = respx .get (f"{ API_ORIGIN } /v1/runs/{ RUN_ID } /result" ).mock (
612614 return_value = httpx .Response (200 , json = final_body ())
613615 )
614616 first = cw .sources .run ("src_1" , {"q" : "x" }, max_items = 3 , expected_version = "v" * 64 , idempotency_key = "s-1" )
@@ -626,7 +628,7 @@ def test_sources_version_selectors_are_exclusive(cw: CleanedWeb) -> None:
626628
627629@respx .mock
628630def test_sources_version_conflict (cw : CleanedWeb ) -> None :
629- respx .post (f"{ BROKER } /v1/sources/src_1/run" ).mock (
631+ respx .post (f"{ API_ORIGIN } /v1/sources/src_1/run" ).mock (
630632 return_value = httpx .Response (409 , json = {"detail" : {"code" : "builder_definition_version_conflict" }})
631633 )
632634 with pytest .raises (VersionConflictError ):
0 commit comments