Test case management via SDK
We expose a few methods to perform CRUD operations on test cases. This is helpful for creating internal workflows to manage test cases.
Test case creation (single)
- TypeScript
- Python
typescript
import {createTestCase } from "@gentrace/core";constcaseId = awaitcreateTestCase ({pipelineSlug : "testing-pipeline-id",name : "Test case 1",inputs : {query : "describing an ethical dilemma you encountered and asking for feedback",sender : "Batman",receiver : "Black Widow"},expectedOutputs : {value : "Dear Natasha,\n I have run into a problem..."}});console .log ("Case ID: ",caseId );
python
import gentracegentrace.init(api_key=os.getenv("GENTRACE_API_KEY"),)case_id = gentrace.create_test_case(pipeline_slug="emails",payload={"name": "Test case 1","inputs": {"query": "describing an ethical dilemma you encountered and asking for feedback","sender": "Batman","receiver": "Black Widow"},"expectedOutputs": {"value": "Dear Natasha,\n I have run into a problem..."},},)print(case_id)
Test case creation (multiple)
- TypeScript
- Python
typescript
import {createTestCases } from "@gentrace/core";constcreationCount = awaitcreateTestCases ({pipelineSlug : "emails",testCases : [{name : "Batman -> Black Window #1",inputs : {query : "describing an ethical dilemma you encountered and asking for feedback",sender : "Batman",receiver : "Black Widow"},expectedOutputs : {value : "Dear Natasha,\n I have run into a problem..."}},{name : "Superman -> Wonder Woman #3",inputs : {query : "desperately asking for backup to a tough situation you am in",sender : "Superman",receiver : "Wonder Woman"},expectedOutputs : {value : "Subject: Urgent Assistance Required: Backup Needed Immediately"}}]});console .log ("Creation count: ",creationCount );
python
import gentracegentrace.init(api_key=os.getenv("GENTRACE_API_KEY"),)creation_count = gentrace.create_test_cases(pipeline_slug="emails",payload=[{"name": "Batman -> Black Window #1","inputs": {"query": "describing an ethical dilemma you encountered and asking for feedback","sender": "Batman","receiver": "Black Widow"},"expectedOutputs": {"value": "Dear Natasha,\n I have run into a problem..."},},{"name": "Superman -> Wonder Woman #3","inputs": {"query": "desperately asking for backup to a tough situation you am in","sender": "Superman","receiver": "Wonder Woman"},"expectedOutputs": {"value": "Subject: Urgent Assistance Required: Backup Needed Immediately"},},])print(creation_count)
Update case
- TypeScript
- Python
python
import gentracegentrace.init(api_key=os.getenv("GENTRACE_API_KEY"),)case_id = gentrace.update_test_case(pipeline_slug="emails",payload={"id": "550e8400-e29b-41d4-a716-446655440000","name": "New test case name",# You can also update the archive status, inputs, and expected outputs},)print(case_id)
typescript
import {updateTestCase } from "@gentrace/core";constcaseId = awaitupdateTestCase ({id : "550e8400-e29b-41d4-a716-446655440000",// You can also update the archive status, inputs, and expected outputsname : "New test case name",});console .log ("caseId",caseId );