Skip to content

[python] Add Spector test cases for @responseAsBool and @clientDoc (Azure/typespec-azure#4268)#10409

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-test-case-azure-pull-4268
Draft

[python] Add Spector test cases for @responseAsBool and @clientDoc (Azure/typespec-azure#4268)#10409
Copilot wants to merge 2 commits intomainfrom
copilot/add-test-case-azure-pull-4268

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 16, 2026

Adds Python mock API tests for the @responseAsBool and @clientDoc TCGC decorator specs introduced in Azure/typespec-azure#4268.

Changes

  • Dependency bump: @azure-tools/azure-http-specs0.1.0-alpha.40-dev.5 to pull in the new Spector specs
  • Bug fix — code generation for @responseAsBool: HEAD operations have no response body, but the generator was emitting _deserialize(Literal[True], response.json()), which throws JSONDecodeError at runtime. Fixed in builder_serializer.py by short-circuiting to deserialized = True / deserialized = False when the response type is a literal constant (ConstantType._is_literal), skipping JSON deserialization entirely.
  • New tests (sync + async):
    • test_azure_client_generator_core_response_as_bool[_async] — asserts exists()True (HTTP 204) and not_exists()False (HTTP 404)
    • test_azure_client_generator_core_client_doc[_async] — asserts harvest(Plant(...)) round-trips correctly via POST

Code generation before/after

Before (broken — no body on HEAD response):

if response.status_code == 204:
    deserialized = _deserialize(Literal[True], response.json())  # JSONDecodeError

After:

if response.status_code == 204:
    deserialized = True

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Azure/typespec-azure/pulls/4268/files
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

…ix code generation for HEAD operations

Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/20a83ee7-26e8-4534-b209-4c7b1c2fcff5

Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Apr 16, 2026
Copilot AI changed the title [WIP] Add test case for Azure pull request 4268 [python] Add Spector test cases for @responseAsBool and @clientDoc (Azure/typespec-azure#4268) Apr 16, 2026
Copilot AI requested a review from msyyc April 16, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[python] add test case for https://github.com/Azure/typespec-azure/pull/4268

2 participants