77import pytest
88from _pytest .assertion .rewrite import AssertionRewritingHook
99
10+ from launch .api_client .model .completion_sync_v1_response import (
11+ CompletionSyncV1Response ,
12+ )
1013from launch .model_bundle import ModelBundle
11- from launch .model_endpoint import AsyncEndpoint , ModelEndpoint
14+ from launch .model_endpoint import AsyncEndpoint , ModelEndpoint , SyncEndpoint
1215
1316ROOT_DIR = Path (__file__ ).parent .parent
1417
@@ -98,6 +101,20 @@ def mock_batch_job():
98101 return {"job_id" : "test-batch-job" , "status" : "SUCCESS" }
99102
100103
104+ @pytest .fixture
105+ def mock_list_llm_model_endpoints ():
106+ mock = Mock (spec = SyncEndpoint )
107+ mock .model_endpoint = Mock (spec = ModelEndpoint )
108+ mock .model_endpoint .id = "test-endpoint"
109+ mock .status = Mock (return_value = "READY" )
110+ return [mock ]
111+
112+
113+ @pytest .fixture
114+ def mock_completion_sync_response ():
115+ return CompletionSyncV1Response (status = "SUCCESS" , outputs = ["Deep learning is a subnet of machine learning." ])
116+
117+
101118@pytest .mark .parametrize ("module_name,source_code" , generate_code_chunks ("launch" , "docs" ))
102119def test_docs_examples (
103120 module_name ,
@@ -108,6 +125,7 @@ def test_docs_examples(
108125 mock_model_bundle ,
109126 mock_async_endpoint ,
110127 mock_batch_job ,
128+ mock_list_llm_model_endpoints ,
111129):
112130 mocker .patch ("launch.connection.Connection" , MagicMock ())
113131 mocker .patch ("launch.client.DefaultApi" , MagicMock ())
@@ -120,6 +138,11 @@ def test_docs_examples(
120138 mocker .patch ("launch.client.LaunchClient.create_model_bundle" , MagicMock (return_value = mock_model_bundle ))
121139 mocker .patch ("launch.client.LaunchClient.create_model_endpoint" , MagicMock (return_value = mock_async_endpoint ))
122140 mocker .patch ("launch.client.LaunchClient.get_batch_async_response" , MagicMock (return_value = mock_batch_job ))
141+ mocker .patch (
142+ "launch.client.LaunchClient.list_llm_model_endpoints" , MagicMock (return_value = mock_list_llm_model_endpoints )
143+ )
144+ mocker .patch ("launch.client.LaunchClient.create_llm_model_endpoint" , MagicMock (return_value = mock_async_endpoint ))
145+ mocker .patch ("launch.client.LaunchClient.completion_sync" , MagicMock (return_value = mock_batch_job ))
123146 mocker .patch ("launch.client.Connection.make_request" , MagicMock (return_value = mock_dictionary ))
124147 mocker .patch ("launch.client.requests" , MagicMock ())
125148 mocker .patch ("pydantic.BaseModel.parse_raw" , MagicMock ())
0 commit comments