MCPcopy
hub / github.com/Agenta-AI/agenta / get_testsets

Function get_testsets

api/oss/src/routers/testset_router.py:345–397  ·  view source on GitHub ↗

Get all testsets. Returns: - A list of testset objects. Raises: - `HTTPException` with status code 404 if no testsets are found.

(
    request: Request,
)

Source from the content-addressed store, hash-verified

343
344@router.get("/", operation_id="get_testsets")
345async def get_testsets(
346 request: Request,
347) -> List[TestSetOutputResponse]:
348 """
349 Get all testsets.
350
351 Returns:
352 - A list of testset objects.
353
354 Raises:
355 - `HTTPException` with status code 404 if no testsets are found.
356 """
357
358 try:
359 if is_ee():
360 has_permission = await check_action_access(
361 user_uid=request.state.user_id,
362 project_id=request.state.project_id,
363 permission=Permission.VIEW_TESTSET,
364 )
365 if not has_permission:
366 error_msg = (
367 "You do not have permission to perform this action. "
368 + "Please contact your organization admin."
369 )
370 log.error(error_msg)
371
372 return JSONResponse(
373 status_code=403,
374 content={"detail": error_msg},
375 )
376
377 testsets = await db_manager.fetch_testsets_by_project_id(
378 project_id=request.state.project_id,
379 )
380
381 return [
382 TestSetOutputResponse(
383 _id=str(testset.id), # type: ignore
384 name=testset.name,
385 created_at=str(testset.created_at),
386 updated_at=str(testset.updated_at),
387 )
388 for testset in testsets
389 ]
390
391 except Exception as e:
392 log.exception(f"An error occurred: {str(e)}")
393
394 raise HTTPException(
395 status_code=500,
396 detail=str(e),
397 )
398
399
400@router.get("/{testset_id}/", operation_id="get_single_testset")

Callers

nothing calls this directly

Calls 3

is_eeFunction · 0.90
errorMethod · 0.45

Tested by

no test coverage detected