Skip to content

Commit 3c7646e

Browse files
author
Val Brodsky
committed
Add unit test
1 parent 5235f07 commit 3c7646e

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from labelbox.schema.tool_building.fact_checking_tool import FactCheckingTool
2+
from labelbox.schema.tool_building.step_reasoning_tool import StepReasoningTool
3+
4+
5+
def test_fact_checking_as_dict_default():
6+
tool = FactCheckingTool(name="Fact Checking Tool")
7+
8+
# Get the dictionary representation
9+
tool_dict = tool.asdict()
10+
11+
# Expected dictionary structure
12+
expected_dict = {
13+
"tool": "fact-checking",
14+
"name": "Fact Checking Tool",
15+
"required": False,
16+
"schemaNodeId": None,
17+
"featureSchemaId": None,
18+
"definition": {
19+
"variants": [
20+
{"id": 0, "name": "Accurate"},
21+
{"id": 1, "name": "Inaccurate"},
22+
{"id": 2, "name": "Disputed"},
23+
{"id": 3, "name": "Unsupported", "actions": []},
24+
{"id": 4, "name": "Can't confidently assess", "actions": []},
25+
{"id": 5, "name": "No factual information", "actions": []},
26+
],
27+
"version": 1,
28+
},
29+
}
30+
31+
assert tool_dict == expected_dict
32+
33+
34+
def test_step_reasoning_as_dict_with_actions():
35+
tool = FactCheckingTool(name="Fact Checking Tool")
36+
tool.set_unsupported_step_actions()
37+
tool.set_cant_confidently_assess_step_actions()
38+
tool.set_no_factual_information_step_actions()
39+
40+
# Get the dictionary representation
41+
tool_dict = tool.asdict()
42+
43+
# Expected dictionary structure
44+
expected_dict = {
45+
"tool": "fact-checking",
46+
"name": "Fact Checking Tool",
47+
"required": False,
48+
"schemaNodeId": None,
49+
"featureSchemaId": None,
50+
"definition": {
51+
"variants": [
52+
{"id": 0, "name": "Accurate"},
53+
{"id": 1, "name": "Inaccurate"},
54+
{"id": 2, "name": "Disputed"},
55+
{
56+
"id": 3,
57+
"name": "Unsupported",
58+
"actions": ["writeJustification"],
59+
},
60+
{
61+
"id": 4,
62+
"name": "Can't confidently assess",
63+
"actions": ["writeJustification"],
64+
},
65+
{
66+
"id": 5,
67+
"name": "No factual information",
68+
"actions": ["writeJustification"],
69+
},
70+
],
71+
"version": 1,
72+
},
73+
}
74+
75+
assert tool_dict == expected_dict

0 commit comments

Comments
 (0)