Skip to content

Commit 4aa385a

Browse files
authored
Add test recordings for muti-tool Agent tests (#44344)
* Enable test recordings * Update test asserts
1 parent 2d076c3 commit 4aa385a

File tree

6 files changed

+17
-63
lines changed

6 files changed

+17
-63
lines changed

sdk/ai/azure-ai-projects/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/ai/azure-ai-projects",
5-
"Tag": "python/ai/azure-ai-projects_3268c5ebe1"
5+
"Tag": "python/ai/azure-ai-projects_2214bdebc9"
66
}

sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_code_interpreter_and_function.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,16 @@
1212
All tests use the same tool combination but different inputs and workflows.
1313
"""
1414

15-
import os
16-
import json
17-
import pytest
1815
from test_base import TestBase, servicePreparer
19-
from devtools_testutils import is_live_and_not_recording
16+
from devtools_testutils import recorded_by_proxy, RecordedTransport
2017
from azure.ai.projects.models import PromptAgentDefinition, CodeInterpreterTool, CodeInterpreterToolAuto, FunctionTool
21-
from openai.types.responses.response_input_param import FunctionCallOutput, ResponseInputParam
2218

2319

2420
class TestAgentCodeInterpreterAndFunction(TestBase):
2521
"""Tests for agents using Code Interpreter + Function Tool combination."""
2622

2723
@servicePreparer()
28-
@pytest.mark.skipif(
29-
condition=(not is_live_and_not_recording()),
30-
reason="Skipped because we cannot record network calls with OpenAI client",
31-
)
24+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
3225
def test_calculate_and_save(self, **kwargs):
3326
"""
3427
Test calculation with Code Interpreter and saving with Function Tool.
@@ -84,10 +77,7 @@ def test_calculate_and_save(self, **kwargs):
8477
project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version)
8578

8679
@servicePreparer()
87-
@pytest.mark.skipif(
88-
condition=(not is_live_and_not_recording()),
89-
reason="Skipped because we cannot record network calls with OpenAI client",
90-
)
80+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
9181
def test_generate_data_and_report(self, **kwargs):
9282
"""
9383
Test generating data with Code Interpreter and reporting with Function.

sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_and_code_interpreter.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,17 @@
1212
All tests use the same tool combination but different inputs and workflows.
1313
"""
1414

15-
import os
16-
import pytest
1715
from io import BytesIO
1816
from test_base import TestBase, servicePreparer
19-
from devtools_testutils import is_live_and_not_recording
17+
from devtools_testutils import recorded_by_proxy, RecordedTransport
2018
from azure.ai.projects.models import PromptAgentDefinition, FileSearchTool, CodeInterpreterTool, CodeInterpreterToolAuto
2119

2220

2321
class TestAgentFileSearchAndCodeInterpreter(TestBase):
2422
"""Tests for agents using File Search + Code Interpreter combination."""
2523

2624
@servicePreparer()
27-
@pytest.mark.skipif(
28-
condition=(not is_live_and_not_recording()),
29-
reason="Skipped because we cannot record network calls with OpenAI client",
30-
)
25+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
3126
def test_find_and_analyze_data(self, **kwargs):
3227
"""
3328
Test finding data with File Search and analyzing with Code Interpreter.
@@ -83,10 +78,7 @@ def test_find_and_analyze_data(self, **kwargs):
8378
openai_client.vector_stores.delete(vector_store.id)
8479

8580
@servicePreparer()
86-
@pytest.mark.skipif(
87-
condition=(not is_live_and_not_recording()),
88-
reason="Skipped because we cannot record network calls with OpenAI client",
89-
)
81+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
9082
def test_analyze_code_file(self, **kwargs):
9183
"""
9284
Test finding code file and analyzing it.

sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_and_function.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
All tests use the same tool combination but different inputs and workflows.
1313
"""
1414

15-
import os
1615
import json
17-
import pytest
1816
from io import BytesIO
1917
from test_base import TestBase, servicePreparer
20-
from devtools_testutils import is_live_and_not_recording
18+
from devtools_testutils import recorded_by_proxy, RecordedTransport
2119
from azure.ai.projects.models import PromptAgentDefinition, FileSearchTool, FunctionTool
2220
from openai.types.responses.response_input_param import FunctionCallOutput, ResponseInputParam
2321

@@ -26,10 +24,7 @@ class TestAgentFileSearchAndFunction(TestBase):
2624
"""Tests for agents using File Search + Function Tool combination."""
2725

2826
@servicePreparer()
29-
@pytest.mark.skipif(
30-
condition=(not is_live_and_not_recording()),
31-
reason="Skipped because we cannot record network calls with OpenAI client",
32-
)
27+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
3328
def test_data_analysis_workflow(self, **kwargs):
3429
"""
3530
Test data analysis workflow: upload data, search, save results.
@@ -160,10 +155,7 @@ def test_data_analysis_workflow(self, **kwargs):
160155
print("Cleanup completed")
161156

162157
@servicePreparer()
163-
@pytest.mark.skipif(
164-
condition=(not is_live_and_not_recording()),
165-
reason="Skipped because we cannot record network calls with OpenAI client",
166-
)
158+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
167159
def test_empty_vector_store_handling(self, **kwargs):
168160
"""
169161
Test how agent handles empty vector store (no files uploaded).
@@ -239,10 +231,7 @@ def test_empty_vector_store_handling(self, **kwargs):
239231
print("Cleanup completed")
240232

241233
@servicePreparer()
242-
@pytest.mark.skipif(
243-
condition=(not is_live_and_not_recording()),
244-
reason="Skipped because we cannot record network calls with OpenAI client",
245-
)
234+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
246235
def test_python_code_file_search(self, **kwargs):
247236
"""
248237
Test searching for Python code files.
@@ -337,10 +326,7 @@ def calculate_sum(numbers):
337326
print("Cleanup completed")
338327

339328
@servicePreparer()
340-
@pytest.mark.skipif(
341-
condition=(not is_live_and_not_recording()),
342-
reason="Skipped because we cannot record network calls with OpenAI client",
343-
)
329+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
344330
def test_multi_turn_search_and_save_workflow(self, **kwargs):
345331
"""
346332
Test multi-turn workflow: search documents, ask follow-ups, save findings.

sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_code_interpreter_function.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,23 @@
1212
All tests use the same 3-tool combination but different inputs and workflows.
1313
"""
1414

15-
import os
16-
import json
17-
import pytest
1815
from io import BytesIO
1916
from test_base import TestBase, servicePreparer
20-
from devtools_testutils import is_live_and_not_recording
17+
from devtools_testutils import recorded_by_proxy, RecordedTransport
2118
from azure.ai.projects.models import (
2219
PromptAgentDefinition,
2320
FileSearchTool,
2421
CodeInterpreterTool,
2522
CodeInterpreterToolAuto,
2623
FunctionTool,
2724
)
28-
from openai.types.responses.response_input_param import FunctionCallOutput, ResponseInputParam
2925

3026

3127
class TestAgentFileSearchCodeInterpreterFunction(TestBase):
3228
"""Tests for agents using File Search + Code Interpreter + Function Tool."""
3329

3430
@servicePreparer()
35-
@pytest.mark.skipif(
36-
condition=(not is_live_and_not_recording()),
37-
reason="Skipped because we cannot record network calls with OpenAI client",
38-
)
31+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
3932
def test_complete_analysis_workflow(self, **kwargs):
4033
"""
4134
Test complete workflow: find data, analyze it, save results.
@@ -106,10 +99,7 @@ def test_complete_analysis_workflow(self, **kwargs):
10699
openai_client.vector_stores.delete(vector_store.id)
107100

108101
@servicePreparer()
109-
@pytest.mark.skipif(
110-
condition=(not is_live_and_not_recording()),
111-
reason="Skipped because we cannot record network calls with OpenAI client",
112-
)
102+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
113103
def test_four_tools_combination(self, **kwargs):
114104
"""
115105
Test with 4 tools: File Search + Code Interpreter + 2 Functions.

sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_multitool_with_conversations.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
"""
1212

1313
import json
14-
import pytest
1514
from io import BytesIO
1615
from test_base import TestBase, servicePreparer
17-
from devtools_testutils import is_live_and_not_recording
16+
from devtools_testutils import recorded_by_proxy, RecordedTransport
1817
from azure.ai.projects.models import (
1918
FunctionTool,
2019
FileSearchTool,
@@ -26,10 +25,7 @@
2625
class TestMultiToolWithConversations(TestBase):
2726

2827
@servicePreparer()
29-
@pytest.mark.skipif(
30-
condition=(not is_live_and_not_recording()),
31-
reason="Skipped because we cannot record network calls with OpenAI client",
32-
)
28+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
3329
def test_file_search_and_function_with_conversation(self, **kwargs):
3430
"""
3531
Test using multiple tools (FileSearch + Function) within one conversation.

0 commit comments

Comments
 (0)