Repository navigation
lro response generation fix #12024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
lro response generation fix #12024
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| changeKind: fix | ||
| packages: | ||
| - "@typespec/http-client-python" | ||
| --- | ||
|
|
||
| Return long-running operation response bodies when generating TypedDict-only models. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/http-client-python/tests/unit/test_lro_response.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| from types import SimpleNamespace | ||
|
|
||
| import pytest | ||
|
|
||
| from pygen.codegen.serializers.builder_serializer import LROOperationSerializer | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session", autouse=True) | ||
| def testserver(): | ||
| yield | ||
|
|
||
|
|
||
| class _TestLROOperationSerializer(LROOperationSerializer): | ||
| def response_headers_and_deserialization(self, builder, response): | ||
| return ["deserialized = response.json()"] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("models_mode", [None, "dpg"]) | ||
| @pytest.mark.parametrize("generate_typeddict_only", [False, True]) | ||
| def test_lro_response_is_available_for_deserialization(models_mode, generate_typeddict_only): | ||
| code_model = SimpleNamespace( | ||
| options={"models-mode": models_mode}, | ||
| generate_typeddict_only=generate_typeddict_only, | ||
| get_serialize_namespace=lambda *args, **kwargs: "test", | ||
| ) | ||
| serializer = _TestLROOperationSerializer(code_model, async_mode=False, client_namespace="test") | ||
| operation = SimpleNamespace( | ||
| lro_response=SimpleNamespace(headers=[], type=object()), | ||
| ) | ||
|
|
||
| generated = serializer.get_long_running_output(operation) | ||
|
|
||
| assert " response = pipeline_response.http_response" in generated | ||
| assert " deserialized = response.json()" in generated | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.