@typespec/http-client-python 0.19.1 → 0.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/emitter/http.js +8 -0
- package/dist/emitter/http.js.map +1 -1
- package/dist/emitter/utils.d.ts.map +1 -1
- package/dist/emitter/utils.js +4 -0
- package/dist/emitter/utils.js.map +1 -1
- package/emitter/src/http.ts +8 -0
- package/emitter/src/utils.ts +4 -0
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/ci/conf.py +57 -0
- package/eng/scripts/ci/run_sphinx_build.py +117 -0
- package/eng/scripts/setup/__pycache__/package_manager.cpython-311.pyc +0 -0
- package/eng/scripts/setup/__pycache__/venvtools.cpython-311.pyc +0 -0
- package/generator/build/lib/pygen/codegen/models/operation.py +3 -3
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +29 -12
- package/generator/build/lib/pygen/codegen/serializers/parameter_serializer.py +3 -1
- package/generator/build/lib/pygen/codegen/templates/macros.jinja2 +33 -15
- package/generator/build/lib/pygen/codegen/templates/operation_tools.jinja2 +1 -15
- package/generator/component-detection-pip-report.json +6 -6
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/operation.py +3 -3
- package/generator/pygen/codegen/serializers/builder_serializer.py +29 -12
- package/generator/pygen/codegen/serializers/parameter_serializer.py +3 -1
- package/generator/pygen/codegen/templates/macros.jinja2 +33 -15
- package/generator/pygen/codegen/templates/operation_tools.jinja2 +1 -15
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_versioning_previewversion_async.py +53 -0
- package/generator/test/azure/mock_api_tests/test_azure_versioning_previewversion.py +50 -0
- package/generator/test/azure/requirements.txt +1 -0
- package/generator/test/azure/tox.ini +16 -8
- package/generator/test/dev_requirements.txt +4 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py +1 -2
- package/generator/test/generic_mock_api_tests/asynctests/test_versioning_removed_async.py +16 -5
- package/generator/test/generic_mock_api_tests/test_encode_bytes.py +1 -2
- package/generator/test/generic_mock_api_tests/test_typetest_scalar.py +5 -0
- package/generator/test/generic_mock_api_tests/test_versioning_removed.py +16 -5
- package/generator/test/unbranded/tox.ini +16 -8
- package/package.json +2 -2
- package/eng/scripts/setup/__pycache__/package_manager.cpython-39.pyc +0 -0
- package/eng/scripts/setup/__pycache__/venvtools.cpython-39.pyc +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
import pytest
|
|
7
|
+
from specs.azure.versioning.previewversion import PreviewVersionClient
|
|
8
|
+
from specs.azure.versioning.previewversion.models import UpdateWidgetColorRequest
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture
|
|
12
|
+
def client():
|
|
13
|
+
with PreviewVersionClient() as client:
|
|
14
|
+
yield client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.fixture
|
|
18
|
+
def stable_client():
|
|
19
|
+
with PreviewVersionClient(api_version="2024-06-01") as client:
|
|
20
|
+
yield client
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_get_widget(client: PreviewVersionClient):
|
|
24
|
+
result = client.get_widget(id="widget-123")
|
|
25
|
+
assert result.id == "widget-123"
|
|
26
|
+
assert result.name == "Sample Widget"
|
|
27
|
+
assert result.color == "blue"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_update_widget_color(client: PreviewVersionClient):
|
|
31
|
+
color_update = UpdateWidgetColorRequest(color="red")
|
|
32
|
+
result = client.update_widget_color(id="widget-123", color_update=color_update)
|
|
33
|
+
assert result.id == "widget-123"
|
|
34
|
+
assert result.name == "Sample Widget"
|
|
35
|
+
assert result.color == "red"
|
|
36
|
+
|
|
37
|
+
with pytest.raises(ValueError):
|
|
38
|
+
with PreviewVersionClient(api_version="2024-06-01") as stable_client:
|
|
39
|
+
stable_client.update_widget_color(id="widget-123", color_update=color_update)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_list_widgets(stable_client: PreviewVersionClient):
|
|
43
|
+
result = stable_client.list_widgets(name="test")
|
|
44
|
+
assert len(result.widgets) == 1
|
|
45
|
+
assert result.widgets[0].id == "widget-1"
|
|
46
|
+
assert result.widgets[0].name == "test"
|
|
47
|
+
|
|
48
|
+
with pytest.raises(ValueError):
|
|
49
|
+
with PreviewVersionClient(api_version="2024-06-01") as client:
|
|
50
|
+
client.list_widgets(name="test", color="test")
|
|
@@ -30,6 +30,7 @@ azure-mgmt-core==1.6.0
|
|
|
30
30
|
-e ./generated/azure-resource-manager-operation-templates
|
|
31
31
|
-e ./generated/azure-resource-manager-resources
|
|
32
32
|
-e ./generated/azure-resource-manager-method-subscription-id
|
|
33
|
+
-e ./generated/azure-versioning-previewversion
|
|
33
34
|
-e ./generated/client-namespace
|
|
34
35
|
-e ./generated/azure-payload-pageable
|
|
35
36
|
-e ./generated/client-naming
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[tox]
|
|
2
|
-
envlist=base, lint, mypy, pyright, apiview
|
|
2
|
+
envlist=base, lint, mypy, pyright, apiview, sphinx
|
|
3
3
|
skipsdist=True
|
|
4
4
|
|
|
5
5
|
[testenv:ci]
|
|
@@ -7,21 +7,22 @@ deps=
|
|
|
7
7
|
-r requirements.txt
|
|
8
8
|
commands =
|
|
9
9
|
# pytest
|
|
10
|
-
|
|
10
|
+
{[testenv:test]commands}
|
|
11
11
|
|
|
12
12
|
# pylint
|
|
13
|
-
|
|
14
|
-
python ../../../eng/scripts/ci/run_pylint.py -t azure -s "generated" {posargs}
|
|
13
|
+
{[testenv:lint]commands}
|
|
15
14
|
|
|
16
15
|
# mypy
|
|
17
|
-
|
|
16
|
+
{[testenv:mypy]commands}
|
|
18
17
|
|
|
19
18
|
# pyright
|
|
20
|
-
|
|
19
|
+
{[testenv:pyright]commands}
|
|
21
20
|
|
|
22
21
|
# apiview
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
{[testenv:apiview]commands}
|
|
23
|
+
|
|
24
|
+
# sphinx docstring validation
|
|
25
|
+
{[testenv:sphinx]commands}
|
|
25
26
|
|
|
26
27
|
[testenv:test]
|
|
27
28
|
deps=
|
|
@@ -54,3 +55,10 @@ deps=
|
|
|
54
55
|
commands =
|
|
55
56
|
pip install apiview-stub-generator==0.3.19 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
|
|
56
57
|
python ../../../eng/scripts/ci/run_apiview.py -t azure -s "generated" {posargs}
|
|
58
|
+
|
|
59
|
+
[testenv:sphinx]
|
|
60
|
+
basepython = python3.10
|
|
61
|
+
deps=
|
|
62
|
+
-r requirements.txt
|
|
63
|
+
commands =
|
|
64
|
+
python ../../../eng/scripts/ci/run_sphinx_build.py -t azure -s "generated" {posargs}
|
|
@@ -124,5 +124,4 @@ async def test_response_body(client: BytesClient, png_data: bytes):
|
|
|
124
124
|
assert expected == await client.response_body.base64()
|
|
125
125
|
assert b"".join([d async for d in (await client.response_body.octet_stream())]) == png_data
|
|
126
126
|
assert b"".join([d async for d in (await client.response_body.custom_content_type())]) == png_data
|
|
127
|
-
|
|
128
|
-
# assert expected == await client.response_body.base64_url()
|
|
127
|
+
assert expected == await client.response_body.base64_url()
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import pytest
|
|
7
7
|
from versioning.removed.aio import RemovedClient
|
|
8
|
-
from versioning.removed.models import ModelV2, EnumV2
|
|
8
|
+
from versioning.removed.models import ModelV2, EnumV2, ModelV3, EnumV3
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@pytest.fixture
|
|
@@ -22,7 +22,18 @@ async def test_v2(client: RemovedClient):
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@pytest.mark.asyncio
|
|
25
|
-
async def test_model_v3(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
async def test_model_v3():
|
|
26
|
+
async with RemovedClient(endpoint="http://localhost:3000", version="v1") as client1:
|
|
27
|
+
model1 = ModelV3(id="123", enum_prop=EnumV3.ENUM_MEMBER_V1)
|
|
28
|
+
result = await client1.model_v3(model1)
|
|
29
|
+
assert result == model1
|
|
30
|
+
|
|
31
|
+
async with RemovedClient(endpoint="http://localhost:3000", version="v2preview") as client2:
|
|
32
|
+
model2 = ModelV3(id="123")
|
|
33
|
+
result = await client2.model_v3(model2)
|
|
34
|
+
assert result == model2
|
|
35
|
+
|
|
36
|
+
async with RemovedClient(endpoint="http://localhost:3000", version="v2") as client3:
|
|
37
|
+
model3 = ModelV3(id="123", enum_prop=EnumV3.ENUM_MEMBER_V1)
|
|
38
|
+
result = await client3.model_v3(model3)
|
|
39
|
+
assert result == model3
|
|
@@ -119,5 +119,4 @@ def test_response_body(client: BytesClient, png_data: bytes):
|
|
|
119
119
|
assert expected == client.response_body.base64()
|
|
120
120
|
assert b"".join(client.response_body.octet_stream()) == png_data
|
|
121
121
|
assert b"".join(client.response_body.custom_content_type()) == png_data
|
|
122
|
-
|
|
123
|
-
# assert expected == client.response_body.base64_url()
|
|
122
|
+
assert expected == client.response_body.base64_url()
|
|
@@ -51,3 +51,8 @@ def test_decimal128_verify(client: ScalarClient):
|
|
|
51
51
|
def test_decimal_verify(client: ScalarClient):
|
|
52
52
|
prepare = client.decimal_verify.prepare_verify()
|
|
53
53
|
client.decimal_verify.verify(reduce(lambda x, y: x + y, prepare))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# open this test case after adopt new version of http-specs for https://github.com/microsoft/typespec/pull/8807
|
|
57
|
+
# def test_constant_query(client: ScalarClient):
|
|
58
|
+
# client.constant_query.post()
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import pytest
|
|
7
7
|
from versioning.removed import RemovedClient
|
|
8
|
-
from versioning.removed.models import ModelV2, EnumV2
|
|
8
|
+
from versioning.removed.models import ModelV2, EnumV2, ModelV3, EnumV3
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@pytest.fixture
|
|
@@ -20,7 +20,18 @@ def test_v2(client: RemovedClient):
|
|
|
20
20
|
)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
def test_model_v3(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
def test_model_v3():
|
|
24
|
+
client1 = RemovedClient(endpoint="http://localhost:3000", version="v1")
|
|
25
|
+
model1 = ModelV3(id="123", enum_prop=EnumV3.ENUM_MEMBER_V1)
|
|
26
|
+
result = client1.model_v3(model1)
|
|
27
|
+
assert result == model1
|
|
28
|
+
|
|
29
|
+
client2 = RemovedClient(endpoint="http://localhost:3000", version="v2preview")
|
|
30
|
+
model2 = ModelV3(id="123")
|
|
31
|
+
result = client2.model_v3(model2)
|
|
32
|
+
assert result == model2
|
|
33
|
+
|
|
34
|
+
client3 = RemovedClient(endpoint="http://localhost:3000", version="v2")
|
|
35
|
+
model3 = ModelV3(id="123", enum_prop=EnumV3.ENUM_MEMBER_V1)
|
|
36
|
+
result = client3.model_v3(model3)
|
|
37
|
+
assert result == model3
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[tox]
|
|
2
|
-
envlist=base, lint, mypy, pyright, apiview
|
|
2
|
+
envlist=base, lint, mypy, pyright, apiview, sphinx
|
|
3
3
|
skipsdist=True
|
|
4
4
|
|
|
5
5
|
[testenv:ci]
|
|
@@ -7,21 +7,22 @@ deps=
|
|
|
7
7
|
-r requirements.txt
|
|
8
8
|
commands =
|
|
9
9
|
# pytest
|
|
10
|
-
|
|
10
|
+
{[testenv:test]commands}
|
|
11
11
|
|
|
12
12
|
# pylint
|
|
13
|
-
|
|
14
|
-
python ../../../eng/scripts/ci/run_pylint.py -t unbranded -s "generated" {posargs}
|
|
13
|
+
{[testenv:lint]commands}
|
|
15
14
|
|
|
16
15
|
# mypy
|
|
17
|
-
|
|
16
|
+
{[testenv:mypy]commands}
|
|
18
17
|
|
|
19
18
|
# pyright
|
|
20
|
-
|
|
19
|
+
{[testenv:pyright]commands}
|
|
21
20
|
|
|
22
21
|
# apiview
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
{[testenv:apiview]commands}
|
|
23
|
+
|
|
24
|
+
# sphinx docstring validation
|
|
25
|
+
{[testenv:sphinx]commands}
|
|
25
26
|
|
|
26
27
|
[testenv:test]
|
|
27
28
|
deps=
|
|
@@ -54,3 +55,10 @@ deps=
|
|
|
54
55
|
commands =
|
|
55
56
|
pip install apiview-stub-generator==0.3.19 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
|
|
56
57
|
python ../../../eng/scripts/ci/run_apiview.py -t unbranded -s "generated" {posargs}
|
|
58
|
+
|
|
59
|
+
[testenv:sphinx]
|
|
60
|
+
basepython = python3.10
|
|
61
|
+
deps=
|
|
62
|
+
-r requirements.txt
|
|
63
|
+
commands =
|
|
64
|
+
python ../../../eng/scripts/ci/run_sphinx_build.py -t unbranded -s "generated" {posargs}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-client-python",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec emitter for Python SDKs",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@azure-tools/typespec-azure-resource-manager": "~0.61.0",
|
|
83
83
|
"@azure-tools/typespec-azure-rulesets": "~0.61.0",
|
|
84
84
|
"@azure-tools/typespec-client-generator-core": "~0.61.0",
|
|
85
|
-
"@azure-tools/azure-http-specs": "0.1.0-alpha.
|
|
85
|
+
"@azure-tools/azure-http-specs": "0.1.0-alpha.31",
|
|
86
86
|
"@typespec/compiler": "^1.5.0",
|
|
87
87
|
"@typespec/http": "^1.5.0",
|
|
88
88
|
"@typespec/openapi": "^1.5.0",
|
|
Binary file
|
|
Binary file
|