Skip to content

Commit ad0cc12

Browse files
committed
improve readme
1 parent d7b5cbc commit ad0cc12

File tree

1 file changed

+10
-6
lines changed
  • sdk/ai/azure-ai-projects/tests/samples

1 file changed

+10
-6
lines changed

sdk/ai/azure-ai-projects/tests/samples/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import pytest
1414
import os
1515
from devtools_testutils import recorded_by_proxy, AzureRecordedTestCase, RecordedTransport
1616
from test_base import servicePreparer
17-
from sample_executor import SyncSampleExecutor, get_sample_paths, samplePathPasser
17+
from sample_executor import SyncSampleExecutor, get_sample_paths, SamplePathPasser
1818
from test_samples_helpers import agent_tools_instructions, get_sample_environment_variables_map
1919

2020
class TestSamples(AzureRecordedTestCase):
@@ -34,7 +34,7 @@ class TestSamples(AzureRecordedTestCase):
3434
],
3535
),
3636
)
37-
@samplePathPasser()
37+
@SamplePathPasser()
3838
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
3939
def test_agent_tools_samples(self, sample_path: str, **kwargs) -> None:
4040
env_var_mapping = get_sample_environment_variables_map()
@@ -53,7 +53,7 @@ from devtools_testutils.aio import recorded_by_proxy_async
5353
import os
5454
from devtools_testutils import AzureRecordedTestCase, RecordedTransport
5555
from test_base import servicePreparer
56-
from sample_executor import AsyncSampleExecutor, get_async_sample_paths, samplePathPasser
56+
from sample_executor import AsyncSampleExecutor, get_async_sample_paths, SamplePathPasser
5757
from test_samples_helpers import agent_tools_instructions, get_sample_environment_variables_map
5858

5959
class TestSamplesAsync(AzureRecordedTestCase):
@@ -68,7 +68,7 @@ class TestSamplesAsync(AzureRecordedTestCase):
6868
],
6969
),
7070
)
71-
@samplePathPasser()
71+
@SamplePathPasser()
7272
@recorded_by_proxy_async(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
7373
async def test_agent_tools_samples_async(self, sample_path: str, **kwargs) -> None:
7474
env_var_mapping = get_sample_environment_variables_map()
@@ -96,9 +96,13 @@ servicePreparer = functools.partial(
9696
)
9797
```
9898
- `@pytest.mark.parametrize`: Drives one test per sample file. Use `samples_to_test` or `samples_to_skip` with `get_sample_paths` / `get_async_sample_paths`.
99-
- `@samplePathPasser`: Forwards the sample path to the recorder decorators.
99+
- `@SamplePathPasser`: Forwards the sample path to the recorder decorators.
100100
- `recorded_by_proxy` / `recorded_by_proxy_async`: Wrap tests for recording/playback. Include `RecordedTransport.HTTPX` when samples use httpx in addition to the default `RecordedTransport.AZURE_CORE`.
101-
- `get_sample_environment_variables_map`: Map test env vars to the names expected by samples. Pass `{}` if you already export the sample variables directly. Example:
101+
- `get_sample_environment_variables_map`: Your function that returns a mapping of **sample env-var name** -> **test env-var name**.
102+
- The executor reads values from `**kwargs` using the *test env-var name* (typically injected by `@servicePreparer()`), then sets `os.environ[<sample env-var name>]` before running the sample.
103+
- If your `@servicePreparer()` (or other decorators) already provide the sample env-var names directly (for example, `AZURE_AI_PROJECT_ENDPOINT=...`), pass `{}` to `SyncSampleExecutor` / `AsyncSampleExecutor`.
104+
105+
Example:
102106
```python
103107
def get_sample_environment_variables_map(operation_group: str | None = None) -> dict[str, str]:
104108
return {

0 commit comments

Comments
 (0)