You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable previously skipped client structure and client operation group mock API tests after TCGC 0.67.0 upgrade; remove obsolete `test_spread_record_discriminated_union` tests whose Spector scenario was removed.
Extend publish pipeline to upload emitter bundles to Playground storage account. Update Python emitter to be browser-compatible for use in the TypeSpec playground.
Copy file name to clipboardExpand all lines: .github/instructions/http-client-java.instructions.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,8 +22,11 @@ Steps:
22
22
23
23
Steps:
24
24
25
-
1. Bump the minor or patch version of `@typespec/http-client-java` in the three `package.json` files.
26
-
2. Save the files and run `npm install` in the root so that `package-lock.json` is updated.
25
+
1. Checkout "main" branch, pull the latest changes.
26
+
2. Create a new branch. The name must follow the pattern "publish/http-client-java-<version>". Remind user that this branch must be pushed to remote upstream.
27
+
3. Invoke `pnpm prepare-publish --only @typespec/http-client-java` in repository root. Commit the changes.
28
+
4. Invoke `npm install` in the root to update `package-lock.json`. Commit the changes.
29
+
5. Update the two `package.json` files in `generator/http-client-generator-clientcore-test` and `generator/http-client-generator-test` to match the new version in the root `package.json`. Commit the changes.
27
30
28
31
The publish workflow (to NPM) will be automatically triggered after the PR is merged: https://dev.azure.com/azure-sdk/internal/_build?definitionId=7294
Copy file name to clipboardExpand all lines: .github/skills/python-sdk-spector-mock-api-tests/SKILL.md
+72-59Lines changed: 72 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
name: writing-python-sdk-spector-mock-api-tests
3
-
description: Writes TypeSpec http-client-python generator mock API tests (azure/unbranded/generic) from a Spector case. Use when given a Spector case link or a PR link that modifies Spector cases under http-specs/azure-http-specs.
3
+
description: Writes TypeSpec http-client-python generator mock API tests (azure/unbranded/shared) from a Spector case. Use when given a Spector case link or a PR link that modifies Spector cases under http-specs/azure-http-specs.
4
4
---
5
5
6
6
# Writing python SDK tests from a Spector case
@@ -20,15 +20,15 @@ Spector cases define the **expected request + response**. The goal is to add/ext
2. If the import root and client/model API surface you need are the same (same module path + same client entrypoint), write ONE shared test in `generic_mock_api_tests`.
141
-
3. If import paths differ (or one flavor lacks the needed client), write separate tests under both `azure/mock_api_tests` and `unbranded/mock_api_tests`.
2. If the import root and client/model API surface you need are the same (same module path + same client entrypoint), write ONE shared test in `mock_api/shared`.
141
+
3. If import paths differ (or one flavor lacks the needed client), write separate tests under both `mock_api/azure` and `mock_api/unbranded`.
142
142
143
-
Why: both azure and unbranded tox runs include `../generic_mock_api_tests`, so shared tests are preferred when they can import the same generated package.
143
+
Why: both azure and unbranded tox runs include `mock_api/shared`, so shared tests are preferred when they can import the same generated package.
144
144
145
145
## Step 4 — Regenerate the specific generated client
146
146
147
-
Generated code is gitignored (`packages/http-client-python/generator/test/**/generated/`). You must regenerate the specific spec before writing tests.
147
+
Generated code is gitignored (`packages/http-client-python/tests/generated/`). You must regenerate the specific spec before writing tests.
148
148
149
149
**Compile only the single spec you need** (example for azure-core-page):
> ⚠️ Do NOT run `npm run regenerate` — it compiles ALL specs and takes 40+ minutes. Only regenerate the specific spec you need.
156
+
The `--flavor` flag selects `azure` or `unbranded`. The `--name` flag is a case-insensitive substring match on the package name.
157
+
158
+
> ⚠️ Do NOT run `npx tsx ./eng/scripts/ci/regenerate.ts` without `--name` — it compiles ALL specs and takes 40+ minutes. Only regenerate the specific spec you need.
159
+
> ⚠️ Do NOT use `npm run regenerate -- --flavor ...` — npm may strip the flags. Use `npx tsx` directly.
157
160
158
161
**Verify** the generated client has the expected method:
159
162
160
163
```bash
161
-
grep -r "method_name"generator/test/azure/generated/< name > /
- Prefer extending an existing `test_*.py` when it already imports the same generated module.
168
171
2. In parallel, find the matching async test in `asynctests/`.
169
172
170
-
- If you extend `mock_api_tests/test_<area>.py`, also extend `mock_api_tests/asynctests/test_<area>_async.py` (or create it if missing).
171
-
- If you extend `generic_mock_api_tests/test_<area>.py`, also extend `generic_mock_api_tests/asynctests/test_<area>_async.py`.
173
+
- If you extend `mock_api/azure/test_<area>.py`, also extend `mock_api/azure/asynctests/test_<area>_async.py` (or create it if missing).
174
+
- If you extend `mock_api/shared/test_<area>.py`, also extend `mock_api/shared/asynctests/test_<area>_async.py`.
175
+
- If you extend `mock_api/unbranded/test_<area>.py`, also extend `mock_api/unbranded/asynctests/test_<area>_async.py`.
172
176
173
177
3. If no sync test exists, create a new `test_<area>.py` and also create the async counterpart under `asynctests/`.
174
178
@@ -203,84 +207,93 @@ Practical guidance:
203
207
Async client import patterns (match the folder you’re writing to):
204
208
205
209
- Azure: import `aio` submodule alongside models, e.g. `from specs.<...> import models, aio`, then `async with aio.<Client>()` and `await client.<op>(...)`.
206
-
-Generic/unbranded generated clients often expose `.aio` modules, e.g. `from <pkg>.aio import <Client>`.
210
+
-Shared/unbranded generated clients often expose `.aio` modules, e.g. `from <pkg>.aio import <Client>`.
207
211
208
212
## Step 7 — Dependencies (only when needed)
209
213
210
214
Default: do NOT add new dependencies.
211
215
212
216
Only if your new/extended test imports a package not already available:
3.**Create and activate a virtual environment** (if one does not already exist):
240
258
241
259
```bash
242
-
cd packages/http-client-python/generator/test/<azure|unbranded>
260
+
cd packages/http-client-python/tests
243
261
python -m venv .venv
262
+
# Windows:
263
+
.venv\Scripts\activate
264
+
# Linux/Mac:
244
265
source .venv/bin/activate
245
266
```
246
267
247
-
3.**Install only the dependencies you need.**
248
-
Installing the full `requirements.txt` is slow because it includes every generated SDK. Instead, extract and install only the non-editable dependencies, then install the specific SDK(s) you need:
268
+
4.**Install dependencies and the generated SDK:**
249
269
250
270
```bash
251
-
# Install dependencies from requirements.txt, excluding generated SDKs:
Replace `<sdk-folder-name>` with the folder that matches the SDK under test (e.g., `azure-encode-duration`, `encode-duration`).
261
-
262
-
4.**Start the Spector mock API server.**
263
-
The mock API tests make real HTTP requests, so the Spector server must be running before you execute pytest. Create another terminal, step into the spec package directory, and run the serve command (it runs in the foreground):
278
+
5.**Start the Spector mock API server** in a separate terminal:
264
279
265
280
```bash
266
-
# For azure-http-specs scenarios:
267
-
cd packages/http-client-python/node_modules/@azure-tools/azure-http-specs/
268
-
npm run serve
269
-
270
-
# For http-specs (microsoft/typespec) scenarios:
271
-
cd packages/http-client-python/node_modules/@typespec/http-specs/
Replace `<test_file>` with the file you added or modified. Verify that all tests pass before proceeding.
294
+
Verify that all tests pass before proceeding.
295
+
296
+
> **Important:** If you only added or changed test files, confirming the changed test passes is sufficient. However, if you modified emitter source code (under `generator/` or `emitter/`), you **must** run the full test suite for the affected flavor(s) to catch regressions before proceeding.
0 commit comments