feat(http-client-python): add mock API tests for payload/head scenario#10420
feat(http-client-python): add mock API tests for payload/head scenario#10420Copilot wants to merge 4 commits into
Conversation
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/6b24cfbf-9b6f-4272-afae-99bea1b0548c Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
| "payload/head": { | ||
| namespace: "payload.head", | ||
| }, |
There was a problem hiding this comment.
@copilot I think the configuration is not needed.
There was a problem hiding this comment.
Removed the payload/head entry from regenerate-common.ts in commit 30d4da5.
|
|
||
|
|
||
| def test_content_type_header_in_response(client: HeadClient): | ||
| assert client.content_type_header_in_response() is True |
There was a problem hiding this comment.
Here is part of generated python sdk code:
response_headers = {}
response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type"))
response_headers["x-ms-meta"] = self._deserialize("str", response.headers.get("x-ms-meta"))
if cls:
return cls(pipeline_response, None, response_headers) # type: ignore
return 200 <= response.status_code <= 299
We could add test case to pass "cls" to check the response header.
@copilot
There was a problem hiding this comment.
Added test_content_type_header_in_response_with_cls (sync + async) in commit 30d4da5 that passes cls=lambda x, y, z: z and asserts both Content-Type and x-ms-meta headers from the response.
# Conflicts: # packages/http-client-python/package-lock.json # packages/http-client-python/package.json Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Resolved. The conflicts in |
…ce override; add cls header test Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Adds Python SDK mock API tests for the
payload/headSpector scenario introduced in #10194 — a HEAD operation returningContent-Typeandx-ms-metaresponse headers with no body.Changes
package.json— Bumps@typespec/http-specsto0.1.0-alpha.37(stable version containing thepayload/headspec)mock_api/shared/test_payload_head.py+asynctests/test_payload_head_async.py— Sync and async tests placed inshared/since both azure and unbranded flavors expose identical import paths and API surfaceThe tests cover two scenarios:
The scenario sends a HEAD request to
/payload/head/content-type-header-in-responseand expects a200response withContent-Type: text/plain; charset=utf-8andx-ms-meta: helloheaders. Theclsvariant verifies that response headers are correctly deserialized and accessible via the callback.