@@ -15,8 +15,8 @@ class _TestOutput(BaseModel):
15
15
@pytest .fixture
16
16
def run1 () -> Run [_TestOutput ]:
17
17
return Run [_TestOutput ](
18
- id = "test -id" ,
19
- agent_id = "agent-1 " ,
18
+ id = "run -id" ,
19
+ agent_id = "agent-id " ,
20
20
schema_id = 1 ,
21
21
output = _TestOutput (message = "test output" ),
22
22
duration_seconds = 1.0 ,
@@ -51,10 +51,12 @@ def test_different_agents(self, run1: Run[_TestOutput], run2: Run[_TestOutput]):
51
51
# 1. The output as a JSON object
52
52
# 2. The cost with $ prefix and correct precision
53
53
# 3. The latency with 2 decimal places and 's' suffix
54
- def test_format_output () -> None :
54
+ # 4. The run URL
55
+ @patch ("workflowai.env.WORKFLOWAI_APP_URL" , "https://workflowai.hello" )
56
+ def test_format_output_full ():
55
57
run = Run [_TestOutput ](
56
- id = "test -id" ,
57
- agent_id = "agent-1 " ,
58
+ id = "run -id" ,
59
+ agent_id = "agent-id " ,
58
60
schema_id = 1 ,
59
61
output = _TestOutput (message = "hello" ),
60
62
duration_seconds = 1.23 ,
@@ -68,15 +70,17 @@ def test_format_output() -> None:
68
70
}
69
71
==================================================
70
72
Cost: $ 0.00100
71
- Latency: 1.23s"""
73
+ Latency: 1.23s
74
+ URL: https://workflowai.hello/_/agents/agent-id/runs/run-id"""
72
75
73
76
assert run .format_output () == expected
74
77
75
78
76
- def test_format_output_very_low_cost () -> None :
79
+ @patch ("workflowai.env.WORKFLOWAI_APP_URL" , "https://workflowai.hello" )
80
+ def test_format_output_very_low_cost ():
77
81
run = Run [_TestOutput ](
78
- id = "test -id" ,
79
- agent_id = "agent-1 " ,
82
+ id = "run -id" ,
83
+ agent_id = "agent-id " ,
80
84
schema_id = 1 ,
81
85
output = _TestOutput (message = "hello" ),
82
86
duration_seconds = 1.23 ,
@@ -90,18 +94,21 @@ def test_format_output_very_low_cost() -> None:
90
94
}
91
95
==================================================
92
96
Cost: $ 0.00005
93
- Latency: 1.23s"""
97
+ Latency: 1.23s
98
+ URL: https://workflowai.hello/_/agents/agent-id/runs/run-id"""
94
99
95
100
assert run .format_output () == expected
96
101
97
102
98
103
# Test that format_output works correctly when cost and latency are not provided:
99
104
# 1. The output is still formatted as a JSON object
100
105
# 2. No cost or latency lines are included in the output
101
- def test_format_output_no_cost_latency () -> None :
106
+ # 3. The run URL is still included
107
+ @patch ("workflowai.env.WORKFLOWAI_APP_URL" , "https://workflowai.hello" )
108
+ def test_format_output_no_cost_latency ():
102
109
run = Run [_TestOutput ](
103
- id = "test -id" ,
104
- agent_id = "agent-1 " ,
110
+ id = "run -id" ,
111
+ agent_id = "agent-id " ,
105
112
schema_id = 1 ,
106
113
output = _TestOutput (message = "hello" ),
107
114
)
@@ -111,12 +118,13 @@ def test_format_output_no_cost_latency() -> None:
111
118
{
112
119
"message": "hello"
113
120
}
114
- =================================================="""
121
+ ==================================================
122
+ URL: https://workflowai.hello/_/agents/agent-id/runs/run-id"""
115
123
116
124
assert run .format_output () == expected
117
125
118
126
119
127
class TestRunURL :
120
128
@patch ("workflowai.env.WORKFLOWAI_APP_URL" , "https://workflowai.hello" )
121
129
def test_run_url (self , run1 : Run [_TestOutput ]):
122
- assert run1 .run_url == "https://workflowai.hello/_/agents/agent-1 /runs/test -id"
130
+ assert run1 .run_url == "https://workflowai.hello/_/agents/agent-id /runs/run -id"
0 commit comments