-
Notifications
You must be signed in to change notification settings - Fork 61
add support and tests for anything #946
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5ae8374
add support and tests for anything
iscai-msft 82026a8
update changelog and bump version
iscai-msft 2aeb882
fix unittests
iscai-msft 01eb6f9
change m4 and core veresion to~
iscai-msft 4861b04
deal with objects and anything as any
iscai-msft 4ba4a2b
Merge branch 'add_object_support' of https://github.com/Azure/autores…
iscai-msft 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
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 |
|---|---|---|
|
|
@@ -27,9 +27,9 @@ contact [[email protected]](mailto:[email protected]) with any additio | |
| pass-thru: | ||
| - model-deduplicator | ||
| - subset-reducer | ||
| version: ^3.1.0 | ||
| version: ~3.3.0 | ||
| use-extension: | ||
| "@autorest/modelerfour": ^4.15.456 | ||
| "@autorest/modelerfour": ~4.19.1 | ||
|
|
||
| modelerfour: | ||
| group-parameters: true | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
|
|
||
| __all__ = [ | ||
| "AzureKeyCredentialSchema", | ||
| "AnySchema", | ||
| "BaseModel", | ||
| "BaseSchema", | ||
| "CodeModel", | ||
|
|
||
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
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
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
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,58 @@ | ||
| # -------------------------------------------------------------------------- | ||
| # | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # | ||
| # The MIT License (MIT) | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the ""Software""), to | ||
| # deal in the Software without restriction, including without limitation the | ||
| # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
| # sell copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in | ||
| # all copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
| # IN THE SOFTWARE. | ||
| # | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
| from async_generator import yield_, async_generator | ||
| from anything.aio import AnythingClient | ||
|
|
||
| @pytest.fixture | ||
| @async_generator | ||
| async def client(): | ||
| async with AnythingClient(base_url="http://localhost:3000") as client: | ||
| await yield_(client) | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_get_string(client): | ||
| assert await client.get_string() == 'anything' | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_put_string(client): | ||
| await client.put_string(input="anything") | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_get_object(client): | ||
| assert await client.get_object() == {"message": "An object was successfully returned"} | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_put_object(client): | ||
| await client.put_object({'foo': 'bar'}) | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_get_array(client): | ||
| assert await client.get_array() == ['foo', 'bar'] | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_put_array(client): | ||
| await client.put_array(['foo', 'bar']) |
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,50 @@ | ||
| # -------------------------------------------------------------------------- | ||
| # | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # | ||
| # The MIT License (MIT) | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the ""Software""), to | ||
| # deal in the Software without restriction, including without limitation the | ||
| # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
| # sell copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in | ||
| # all copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
| # IN THE SOFTWARE. | ||
| # | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
| from anything import AnythingClient | ||
|
|
||
| @pytest.fixture | ||
| def client(): | ||
| with AnythingClient(base_url="http://localhost:3000") as client: | ||
| yield client | ||
|
|
||
| def test_get_string(client): | ||
| assert client.get_string() == 'anything' | ||
|
|
||
| def test_put_string(client): | ||
| client.put_string(input="anything") | ||
|
|
||
| def test_get_object(client): | ||
| assert client.get_object() == {"message": "An object was successfully returned"} | ||
|
|
||
| def test_put_object(client): | ||
| client.put_object({'foo': 'bar'}) | ||
|
|
||
| def test_get_array(client): | ||
| assert client.get_array() == ['foo', 'bar'] | ||
|
|
||
| def test_put_array(client): | ||
| client.put_array(['foo', 'bar']) |
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
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
20 changes: 20 additions & 0 deletions
20
test/vanilla/Expected/AcceptanceTests/Anything/anything/__init__.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,20 @@ | ||
| # coding=utf-8 | ||
| # -------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # Code generated by Microsoft (R) AutoRest Code Generator. | ||
| # Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| from ._anything_client import AnythingClient | ||
| from ._version import VERSION | ||
|
|
||
| __version__ = VERSION | ||
| __all__ = ["AnythingClient"] | ||
|
|
||
| try: | ||
| from ._patch import patch_sdk # type: ignore | ||
|
|
||
| patch_sdk() | ||
| except ImportError: | ||
| pass |
72 changes: 72 additions & 0 deletions
72
test/vanilla/Expected/AcceptanceTests/Anything/anything/_anything_client.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,72 @@ | ||
| # coding=utf-8 | ||
| # -------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # Code generated by Microsoft (R) AutoRest Code Generator. | ||
| # Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from azure.core import PipelineClient | ||
| from msrest import Deserializer, Serializer | ||
|
|
||
| if TYPE_CHECKING: | ||
| # pylint: disable=unused-import,ungrouped-imports | ||
| from typing import Any, Dict, Optional | ||
|
|
||
| from azure.core.pipeline.transport import HttpRequest, HttpResponse | ||
|
|
||
| from ._configuration import AnythingClientConfiguration | ||
| from .operations import AnythingClientOperationsMixin | ||
|
|
||
|
|
||
| class AnythingClient(AnythingClientOperationsMixin): | ||
| """Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. | ||
|
|
||
| :param str base_url: Service URL | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| base_url=None, # type: Optional[str] | ||
| **kwargs # type: Any | ||
| ): | ||
| # type: (...) -> None | ||
| if not base_url: | ||
| base_url = "http://localhost:3000" | ||
| self._config = AnythingClientConfiguration(**kwargs) | ||
| self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) | ||
|
|
||
| client_models = {} # type: Dict[str, Any] | ||
| self._serialize = Serializer(client_models) | ||
| self._serialize.client_side_validation = False | ||
| self._deserialize = Deserializer(client_models) | ||
|
|
||
| def _send_request(self, http_request, **kwargs): | ||
| # type: (HttpRequest, Any) -> HttpResponse | ||
| """Runs the network request through the client's chained policies. | ||
|
|
||
| :param http_request: The network request you want to make. Required. | ||
| :type http_request: ~azure.core.pipeline.transport.HttpRequest | ||
| :keyword bool stream: Whether the response payload will be streamed. Defaults to True. | ||
| :return: The response of your network call. Does not do error handling on your response. | ||
| :rtype: ~azure.core.pipeline.transport.HttpResponse | ||
| """ | ||
| http_request.url = self._client.format_url(http_request.url) | ||
| stream = kwargs.pop("stream", True) | ||
| pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) | ||
| return pipeline_response.http_response | ||
|
|
||
| def close(self): | ||
| # type: () -> None | ||
| self._client.close() | ||
|
|
||
| def __enter__(self): | ||
| # type: () -> AnythingClient | ||
| self._client.__enter__() | ||
| return self | ||
|
|
||
| def __exit__(self, *exc_details): | ||
| # type: (Any) -> None | ||
| self._client.__exit__(*exc_details) |
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.