@@ -152,7 +152,9 @@ def test_lemur_summarize_succeeds(httpx_mock: HTTPXMock):
152152 """
153153
154154 # create a mock response of a LemurSummaryResponse
155- mock_lemur_summary = factories .generate_dict_factory (factories .LemurTaskResponse )()
155+ mock_lemur_summary = factories .generate_dict_factory (
156+ factories .LemurSummaryResponse
157+ )()
156158
157159 # mock the specific endpoints
158160 httpx_mock .add_response (
@@ -204,6 +206,72 @@ def test_lemur_summarize_fails(httpx_mock: HTTPXMock):
204206 assert len (httpx_mock .get_requests ()) == 1
205207
206208
209+ def test_lemur_action_items_succeeds (httpx_mock : HTTPXMock ):
210+ """
211+ Tests whether generating action items for a transcript via LeMUR succeeds.
212+ """
213+
214+ # create a mock response of a LemurActionItemsResponse
215+ mock_lemur_action_items = factories .generate_dict_factory (
216+ factories .LemurActionItemsResponse
217+ )()
218+
219+ # mock the specific endpoints
220+ httpx_mock .add_response (
221+ url = f"{ aai .settings .base_url } { ENDPOINT_LEMUR } /action-items" ,
222+ status_code = httpx .codes .OK ,
223+ method = "POST" ,
224+ json = mock_lemur_action_items ,
225+ )
226+
227+ # mimic the usage of the SDK
228+ transcript = aai .Transcript (str (uuid .uuid4 ()))
229+
230+ lemur = aai .Lemur (sources = [aai .LemurSource (transcript )])
231+ result = lemur .action_items (
232+ context = "Customers asking for help with resolving their problem" ,
233+ answer_format = "Three bullet points" ,
234+ )
235+
236+ assert isinstance (result , aai .LemurActionItemsResponse )
237+
238+ action_items = result .response
239+
240+ # check the response
241+ assert action_items == mock_lemur_action_items ["response" ]
242+
243+ # check whether we mocked everything
244+ assert len (httpx_mock .get_requests ()) == 1
245+
246+
247+ def test_lemur_action_items_fails (httpx_mock : HTTPXMock ):
248+ """
249+ Tests whether generating action items for a transcript via LeMUR fails.
250+ """
251+
252+ # mock the specific endpoints
253+ httpx_mock .add_response (
254+ url = f"{ aai .settings .base_url } { ENDPOINT_LEMUR } /action-items" ,
255+ status_code = httpx .codes .INTERNAL_SERVER_ERROR ,
256+ method = "POST" ,
257+ json = {"error" : "something went wrong" },
258+ )
259+
260+ # mimic the usage of the SDK
261+ transcript = aai .Transcript (str (uuid .uuid4 ()))
262+
263+ lemur = aai .Lemur (sources = [aai .LemurSource (transcript )])
264+
265+ with pytest .raises (aai .LemurError ):
266+ lemur .action_items (
267+ context = "Customers asking for help with resolving their problem" ,
268+ answer_format = "Three bullet points" ,
269+ )
270+
271+ # check whether we mocked everything
272+ assert len (httpx_mock .get_requests ()) == 1
273+
274+
207275def test_lemur_task_succeeds (httpx_mock : HTTPXMock ):
208276 """
209277 Tests whether creating a task request succeeds.
0 commit comments