@@ -15,8 +15,8 @@ class _TestOutput(BaseModel):
1515@pytest .fixture
1616def run1 () -> Run [_TestOutput ]:
1717 return Run [_TestOutput ](
18- id = "test -id" ,
19- agent_id = "agent-1 " ,
18+ id = "run -id" ,
19+ agent_id = "agent-id " ,
2020 schema_id = 1 ,
2121 output = _TestOutput (message = "test output" ),
2222 duration_seconds = 1.0 ,
@@ -51,10 +51,12 @@ def test_different_agents(self, run1: Run[_TestOutput], run2: Run[_TestOutput]):
5151# 1. The output as a JSON object
5252# 2. The cost with $ prefix and correct precision
5353# 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 ():
5557 run = Run [_TestOutput ](
56- id = "test -id" ,
57- agent_id = "agent-1 " ,
58+ id = "run -id" ,
59+ agent_id = "agent-id " ,
5860 schema_id = 1 ,
5961 output = _TestOutput (message = "hello" ),
6062 duration_seconds = 1.23 ,
@@ -68,15 +70,17 @@ def test_format_output() -> None:
6870}
6971==================================================
7072Cost: $ 0.00100
71- Latency: 1.23s"""
73+ Latency: 1.23s
74+ URL: https://workflowai.hello/_/agents/agent-id/runs/run-id"""
7275
7376 assert run .format_output () == expected
7477
7578
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 ():
7781 run = Run [_TestOutput ](
78- id = "test -id" ,
79- agent_id = "agent-1 " ,
82+ id = "run -id" ,
83+ agent_id = "agent-id " ,
8084 schema_id = 1 ,
8185 output = _TestOutput (message = "hello" ),
8286 duration_seconds = 1.23 ,
@@ -90,18 +94,21 @@ def test_format_output_very_low_cost() -> None:
9094}
9195==================================================
9296Cost: $ 0.00005
93- Latency: 1.23s"""
97+ Latency: 1.23s
98+ URL: https://workflowai.hello/_/agents/agent-id/runs/run-id"""
9499
95100 assert run .format_output () == expected
96101
97102
98103# Test that format_output works correctly when cost and latency are not provided:
99104# 1. The output is still formatted as a JSON object
100105# 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 ():
102109 run = Run [_TestOutput ](
103- id = "test -id" ,
104- agent_id = "agent-1 " ,
110+ id = "run -id" ,
111+ agent_id = "agent-id " ,
105112 schema_id = 1 ,
106113 output = _TestOutput (message = "hello" ),
107114 )
@@ -111,12 +118,13 @@ def test_format_output_no_cost_latency() -> None:
111118{
112119 "message": "hello"
113120}
114- =================================================="""
121+ ==================================================
122+ URL: https://workflowai.hello/_/agents/agent-id/runs/run-id"""
115123
116124 assert run .format_output () == expected
117125
118126
119127class TestRunURL :
120128 @patch ("workflowai.env.WORKFLOWAI_APP_URL" , "https://workflowai.hello" )
121129 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