Skip to content

Commit 94afd69

Browse files
authored
Add tests recordings for "files" operations tests (#44232)
1 parent 71e6005 commit 94afd69

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
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_6fcd9d72cc"
5+
"Tag": "python/ai/azure-ai-projects_9e7a9707f6"
66
}

sdk/ai/azure-ai-projects/tests/files/test_files.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@
77
import pytest
88
from pathlib import Path
99
from test_base import TestBase, servicePreparer
10-
from devtools_testutils import recorded_by_proxy, is_live_and_not_recording
10+
from devtools_testutils import recorded_by_proxy, RecordedTransport
1111

1212

13-
@pytest.mark.skipif(
14-
condition=(not is_live_and_not_recording()),
15-
reason="Skipped because we cannot record network calls with AOAI client",
16-
)
1713
class TestFiles(TestBase):
1814

1915
# To run this test, use the following command in the \sdk\ai\azure-ai-projects folder:
2016
# cls & pytest tests\test_files.py::TestFiles::test_files -s
2117
@servicePreparer()
22-
@recorded_by_proxy
18+
@recorded_by_proxy(RecordedTransport.HTTPX)
2319
def test_files(self, **kwargs):
2420

2521
file_purpose = self.test_files_params["file_purpose"]

sdk/ai/azure-ai-projects/tests/files/test_files_async.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@
88
from pathlib import Path
99
from test_base import TestBase, servicePreparer
1010
from devtools_testutils.aio import recorded_by_proxy_async
11-
from devtools_testutils import is_live_and_not_recording
11+
from devtools_testutils import RecordedTransport
1212

1313

14-
@pytest.mark.skipif(
15-
condition=(not is_live_and_not_recording()),
16-
reason="Skipped because we cannot record network calls with AOAI client",
17-
)
1814
class TestFilesAsync(TestBase):
1915

2016
# To run this test, use the following command in the \sdk\ai\azure-ai-projects folder:
2117
# cls & pytest tests\test_files_async.py::TestFilesAsync::test_files_async -s
2218
@servicePreparer()
23-
@recorded_by_proxy_async
19+
@recorded_by_proxy_async(RecordedTransport.HTTPX)
2420
async def test_files_async(self, **kwargs):
2521

2622
file_purpose = self.test_files_params["file_purpose"]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Force LF line endings for test files to ensure consistent binary representation
2+
# across Windows and Linux platforms.
3+
#
4+
# These files are read and sent as binary REST API request payloads in tests.
5+
# Without consistent line endings, the binary content differs between platforms,
6+
# causing recorded test traffic to be inconsistent and test playback to fail.
7+
#
8+
# By enforcing LF endings, the binary representation remains identical regardless
9+
# of the platform where tests are executed.
10+
11+
*.jsonl text eol=lf

sdk/ai/azure-ai-projects/tests/test_data/files/test_file.jsonl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What is the largest mammal?"}, {"role": "assistant", "content": "Blue Whale. Quite a big fish isn't it? Oh wait, it's not a fish!"}]}
88
{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What's the highest mountain peak?"}, {"role": "assistant", "content": "Everest. Brace yourself, it's not a walk in the park."}]}
99
{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "Who invented the telephone?"}, {"role": "assistant", "content": "A guy named Alexander Graham Bell. Bet you didn't guess that one!"}]}
10-
{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What is the distance from Earth to the Sun?"}, {"role": "assistant", "content": "About 93 million miles. Just a quick drive, really."}]}
10+
{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What is the distance from Earth to the Sun?"}, {"role": "assistant", "content": "About 93 million miles. Just a quick drive, really."}]}

0 commit comments

Comments
 (0)