-
Notifications
You must be signed in to change notification settings - Fork 61
[Copilot] Add test cases from TypeSpec PR #7693 #3107
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
8 commits
Select commit
Hold shift + click to select a range
7956891
Initial plan
Copilot b03e9c1
Add test cases from TypeSpec PR #7693
Copilot 3c5775e
Add changelog entry for test cases
Copilot 94fe6c4
Run black formatter on Python test files
Copilot 3db07e8
Revert changelog entry for test cases per feedback
Copilot 0e38b83
Merge branch 'main' into copilot/fix-3106
msyyc 2936d76
add changelog
msyyc c8f9c1e
Merge branch 'main' into copilot/fix-3106
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| changeKind: internal | ||
| packages: | ||
| - "@azure-tools/typespec-python" | ||
| --- | ||
|
|
||
| Add test cases |
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
30 changes: 30 additions & 0 deletions
30
.../typespec-python/test/azure/mock_api_tests/asynctests/test_azure_arm_largeheader_async.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,30 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
| from azure.resourcemanager.largeheader.aio import LargeHeaderClient | ||
| from azure.resourcemanager.largeheader import models | ||
|
|
||
| SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000" | ||
| RESOURCE_GROUP_NAME = "test-rg" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def client(credential, authentication_policy): | ||
| async with LargeHeaderClient( | ||
| credential, SUBSCRIPTION_ID, "http://localhost:3000", authentication_policy=authentication_policy | ||
| ) as client: | ||
| yield client | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_large_headers_begin_two6_k(client: LargeHeaderClient): | ||
| result = await ( | ||
| await client.large_headers.begin_two6_k( | ||
| resource_group_name=RESOURCE_GROUP_NAME, | ||
| large_header_name="header1", | ||
| ) | ||
| ).result() | ||
| assert result == models.CancelResult(succeeded=True) |
36 changes: 36 additions & 0 deletions
36
.../typespec-python/test/azure/mock_api_tests/asynctests/test_azure_arm_nonresource_async.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,36 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
| from azure.resourcemanager.nonresource.aio import NonResourceClient | ||
| from azure.resourcemanager.nonresource import models | ||
|
|
||
| SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000" | ||
| RESOURCE_GROUP_NAME = "test-rg" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def client(credential, authentication_policy): | ||
| async with NonResourceClient( | ||
| credential, SUBSCRIPTION_ID, "http://localhost:3000", authentication_policy=authentication_policy | ||
| ) as client: | ||
| yield client | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_non_resource_create(client: NonResourceClient): | ||
| result = await client.non_resource_operations.create( | ||
| location="eastus", parameter="hello", body=models.NonResource(id="id", name="hello", type="nonResource") | ||
| ) | ||
| assert result == models.NonResource(id="id", name="hello", type="nonResource") | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_non_resource_get(client: NonResourceClient): | ||
| result = await client.non_resource_operations.get( | ||
| location="eastus", | ||
| parameter="hello", | ||
| ) | ||
| assert result == models.NonResource(id="id", name="hello", type="nonResource") |
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
...sts/asynctests/test_azure_client_generator_core_deserialize_empty_string_as_null_async.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 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
| from specs.azure.clientgenerator.core.emptystring.aio import DeserializeEmptyStringAsNullClient | ||
| from specs.azure.clientgenerator.core.emptystring import models | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def client(): | ||
| async with DeserializeEmptyStringAsNullClient() as client: | ||
| yield client | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_get(client: DeserializeEmptyStringAsNullClient): | ||
| result = await client.get() | ||
| assert result == models.ResponseModel(sample_url="") |
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
19 changes: 19 additions & 0 deletions
19
.../typespec-python/test/azure/mock_api_tests/asynctests/test_azure_encode_duration_async.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,19 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
| from specs.azure.encode.duration.aio import DurationClient | ||
| from specs.azure.encode.duration import models | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def client(): | ||
| async with DurationClient() as client: | ||
| yield client | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_duration_constant(client: DurationClient): | ||
| await client.duration_constant(models.DurationModel(input="1.02:59:59.5000000")) |
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
27 changes: 27 additions & 0 deletions
27
packages/typespec-python/test/azure/mock_api_tests/test_azure_arm_largeheader.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,27 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
| from azure.resourcemanager.largeheader import LargeHeaderClient | ||
| from azure.resourcemanager.largeheader import models | ||
|
|
||
| SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000" | ||
| RESOURCE_GROUP_NAME = "test-rg" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def client(credential, authentication_policy): | ||
| with LargeHeaderClient( | ||
| credential, SUBSCRIPTION_ID, "http://localhost:3000", authentication_policy=authentication_policy | ||
| ) as client: | ||
| yield client | ||
|
|
||
|
|
||
| def test_large_headers_begin_two6_k(client: LargeHeaderClient): | ||
| result = client.large_headers.begin_two6_k( | ||
| resource_group_name=RESOURCE_GROUP_NAME, | ||
| large_header_name="header1", | ||
| ).result() | ||
| assert result == models.CancelResult(succeeded=True) |
34 changes: 34 additions & 0 deletions
34
packages/typespec-python/test/azure/mock_api_tests/test_azure_arm_nonresource.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,34 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
| from azure.resourcemanager.nonresource import NonResourceClient | ||
| from azure.resourcemanager.nonresource import models | ||
|
|
||
| SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000" | ||
| RESOURCE_GROUP_NAME = "test-rg" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def client(credential, authentication_policy): | ||
| with NonResourceClient( | ||
| credential, SUBSCRIPTION_ID, "http://localhost:3000", authentication_policy=authentication_policy | ||
| ) as client: | ||
| yield client | ||
|
|
||
|
|
||
| def test_non_resource_create(client: NonResourceClient): | ||
| result = client.non_resource_operations.create( | ||
| location="eastus", parameter="hello", body=models.NonResource(id="id", name="hello", type="nonResource") | ||
| ) | ||
| assert result == models.NonResource(id="id", name="hello", type="nonResource") | ||
|
|
||
|
|
||
| def test_non_resource_get(client: NonResourceClient): | ||
| result = client.non_resource_operations.get( | ||
| location="eastus", | ||
| parameter="hello", | ||
| ) | ||
| assert result == models.NonResource(id="id", name="hello", type="nonResource") |
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
19 changes: 19 additions & 0 deletions
19
...azure/mock_api_tests/test_azure_client_generator_core_deserialize_empty_string_as_null.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,19 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
| from specs.azure.clientgenerator.core.emptystring import DeserializeEmptyStringAsNullClient | ||
| from specs.azure.clientgenerator.core.emptystring import models | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def client(): | ||
| with DeserializeEmptyStringAsNullClient() as client: | ||
| yield client | ||
|
|
||
|
|
||
| def test_get(client: DeserializeEmptyStringAsNullClient): | ||
| result = client.get() | ||
| assert result == models.ResponseModel(sample_url="") |
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
18 changes: 18 additions & 0 deletions
18
packages/typespec-python/test/azure/mock_api_tests/test_azure_encode_duration.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,18 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| import pytest | ||
| from specs.azure.encode.duration import DurationClient | ||
| from specs.azure.encode.duration import models | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def client(): | ||
| with DurationClient() as client: | ||
| yield client | ||
|
|
||
|
|
||
| def test_duration_constant(client: DurationClient): | ||
| client.duration_constant(models.DurationModel(input="1.02:59:59.5000000")) |
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
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.