7
7
import pytest
8
8
from _pytest .assertion .rewrite import AssertionRewritingHook
9
9
10
+ from launch .api_client .model .completion_sync_v1_response import (
11
+ CompletionSyncV1Response ,
12
+ )
10
13
from launch .model_bundle import ModelBundle
11
- from launch .model_endpoint import AsyncEndpoint , ModelEndpoint
14
+ from launch .model_endpoint import AsyncEndpoint , ModelEndpoint , SyncEndpoint
12
15
13
16
ROOT_DIR = Path (__file__ ).parent .parent
14
17
@@ -98,6 +101,20 @@ def mock_batch_job():
98
101
return {"job_id" : "test-batch-job" , "status" : "SUCCESS" }
99
102
100
103
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
+
101
118
@pytest .mark .parametrize ("module_name,source_code" , generate_code_chunks ("launch" , "docs" ))
102
119
def test_docs_examples (
103
120
module_name ,
@@ -108,6 +125,7 @@ def test_docs_examples(
108
125
mock_model_bundle ,
109
126
mock_async_endpoint ,
110
127
mock_batch_job ,
128
+ mock_list_llm_model_endpoints ,
111
129
):
112
130
mocker .patch ("launch.connection.Connection" , MagicMock ())
113
131
mocker .patch ("launch.client.DefaultApi" , MagicMock ())
@@ -120,6 +138,11 @@ def test_docs_examples(
120
138
mocker .patch ("launch.client.LaunchClient.create_model_bundle" , MagicMock (return_value = mock_model_bundle ))
121
139
mocker .patch ("launch.client.LaunchClient.create_model_endpoint" , MagicMock (return_value = mock_async_endpoint ))
122
140
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 ))
123
146
mocker .patch ("launch.client.Connection.make_request" , MagicMock (return_value = mock_dictionary ))
124
147
mocker .patch ("launch.client.requests" , MagicMock ())
125
148
mocker .patch ("pydantic.BaseModel.parse_raw" , MagicMock ())
0 commit comments