@typespec/http-client-python 0.3.4 → 0.3.5
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/code-model.d.ts.map +1 -1
- package/dist/emitter/code-model.js +15 -3
- package/dist/emitter/code-model.js.map +1 -1
- package/emitter/src/code-model.ts +15 -2
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/setup/__pycache__/venvtools.cpython-38.pyc +0 -0
- package/generator/dev_requirements.txt +1 -1
- package/generator/test/azure/mock_api_tests/asynctests/{test_azure_arm_models_common_types_managed_identity_async.py → test_azure_arm_commonproperties_async.py} +9 -9
- package/generator/test/azure/mock_api_tests/asynctests/{test_azure_arm_models_resource_async.py → test_azure_arm_resource_async.py} +46 -46
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_access_async.py +20 -20
- package/generator/test/azure/mock_api_tests/{test_azure_arm_models_common_types_managed_identity.py → test_azure_arm_commonproperties.py} +9 -9
- package/generator/test/azure/mock_api_tests/{test_azure_arm_models_resource.py → test_azure_arm_resource.py} +46 -46
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_access.py +20 -20
- package/generator/test/azure/requirements.txt +2 -2
- package/generator/test/generic_mock_api_tests/asynctests/test_authentication_async.py +6 -6
- package/generator/test/generic_mock_api_tests/test_authentication.py +6 -6
- package/package.json +5 -5
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import pytest
|
|
7
|
-
from azure.resourcemanager.
|
|
8
|
-
from azure.resourcemanager.
|
|
7
|
+
from azure.resourcemanager.resources import ResourcesClient
|
|
8
|
+
from azure.resourcemanager.resources import models
|
|
9
9
|
|
|
10
10
|
SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000"
|
|
11
11
|
RESOURCE_GROUP_NAME = "test-rg"
|
|
@@ -33,15 +33,15 @@ def test_client_signature(credential, authentication_policy):
|
|
|
33
33
|
)
|
|
34
34
|
for client in [client1, client2]:
|
|
35
35
|
# make sure signautre order is correct
|
|
36
|
-
client.
|
|
36
|
+
client.top_level.get(RESOURCE_GROUP_NAME, "top")
|
|
37
37
|
# make sure signautre name is correct
|
|
38
|
-
client.
|
|
38
|
+
client.top_level.get(
|
|
39
39
|
resource_group_name=RESOURCE_GROUP_NAME, top_level_tracked_resource_name="top"
|
|
40
40
|
)
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
def
|
|
44
|
-
result = client.
|
|
43
|
+
def test_top_level_begin_create_or_replace(client):
|
|
44
|
+
result = client.top_level.begin_create_or_replace(
|
|
45
45
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
46
46
|
top_level_tracked_resource_name="top",
|
|
47
47
|
resource=models.TopLevelTrackedResource(
|
|
@@ -56,12 +56,12 @@ def test_top_level_tracked_resources_begin_create_or_replace(client):
|
|
|
56
56
|
assert result.properties.description == "valid"
|
|
57
57
|
assert result.properties.provisioning_state == "Succeeded"
|
|
58
58
|
assert result.name == "top"
|
|
59
|
-
assert result.type == "Azure.ResourceManager.
|
|
59
|
+
assert result.type == "Azure.ResourceManager.Resources/topLevelTrackedResources"
|
|
60
60
|
assert result.system_data.created_by == "AzureSDK"
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
def
|
|
64
|
-
result = client.
|
|
63
|
+
def test_top_level_begin_update(client):
|
|
64
|
+
result = client.top_level.begin_update(
|
|
65
65
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
66
66
|
top_level_tracked_resource_name="top",
|
|
67
67
|
properties=models.TopLevelTrackedResource(
|
|
@@ -76,20 +76,20 @@ def test_top_level_tracked_resources_begin_update(client):
|
|
|
76
76
|
assert result.properties.description == "valid2"
|
|
77
77
|
assert result.properties.provisioning_state == "Succeeded"
|
|
78
78
|
assert result.name == "top"
|
|
79
|
-
assert result.type == "Azure.ResourceManager.
|
|
79
|
+
assert result.type == "Azure.ResourceManager.Resources/topLevelTrackedResources"
|
|
80
80
|
assert result.system_data.created_by == "AzureSDK"
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
def
|
|
84
|
-
client.
|
|
83
|
+
def test_top_level_begin_delete(client):
|
|
84
|
+
client.top_level.begin_delete(
|
|
85
85
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
86
86
|
top_level_tracked_resource_name="top",
|
|
87
87
|
polling_interval=0, # set polling_interval to 0 s to make the test faster since default is 30s
|
|
88
88
|
).result()
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
def
|
|
92
|
-
response = client.
|
|
91
|
+
def test_top_level_list_by_resource_group(client):
|
|
92
|
+
response = client.top_level.list_by_resource_group(
|
|
93
93
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
94
94
|
)
|
|
95
95
|
result = [r for r in response]
|
|
@@ -98,24 +98,24 @@ def test_top_level_tracked_resources_list_by_resource_group(client):
|
|
|
98
98
|
assert result.properties.description == "valid"
|
|
99
99
|
assert result.properties.provisioning_state == "Succeeded"
|
|
100
100
|
assert result.name == "top"
|
|
101
|
-
assert result.type == "Azure.ResourceManager.
|
|
101
|
+
assert result.type == "Azure.ResourceManager.Resources/topLevelTrackedResources"
|
|
102
102
|
assert result.system_data.created_by == "AzureSDK"
|
|
103
103
|
|
|
104
104
|
|
|
105
|
-
def
|
|
106
|
-
response = client.
|
|
105
|
+
def test_top_level_list_by_subscription(client):
|
|
106
|
+
response = client.top_level.list_by_subscription()
|
|
107
107
|
result = [r for r in response]
|
|
108
108
|
for result in result:
|
|
109
109
|
assert result.location == "eastus"
|
|
110
110
|
assert result.properties.description == "valid"
|
|
111
111
|
assert result.properties.provisioning_state == "Succeeded"
|
|
112
112
|
assert result.name == "top"
|
|
113
|
-
assert result.type == "Azure.ResourceManager.
|
|
113
|
+
assert result.type == "Azure.ResourceManager.Resources/topLevelTrackedResources"
|
|
114
114
|
assert result.system_data.created_by == "AzureSDK"
|
|
115
115
|
|
|
116
116
|
|
|
117
|
-
def
|
|
118
|
-
result = client.
|
|
117
|
+
def test_nested_get(client):
|
|
118
|
+
result = client.nested.get(
|
|
119
119
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
120
120
|
top_level_tracked_resource_name="top",
|
|
121
121
|
nexted_proxy_resource_name="nested",
|
|
@@ -123,12 +123,12 @@ def test_nested_proxy_resources_get(client):
|
|
|
123
123
|
assert result.properties.description == "valid"
|
|
124
124
|
assert result.properties.provisioning_state == "Succeeded"
|
|
125
125
|
assert result.name == "nested"
|
|
126
|
-
assert result.type == "Azure.ResourceManager.
|
|
126
|
+
assert result.type == "Azure.ResourceManager.Resources/topLevelTrackedResources/top/nestedProxyResources"
|
|
127
127
|
assert result.system_data.created_by == "AzureSDK"
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
def
|
|
131
|
-
result = client.
|
|
130
|
+
def test_nested_begin_create_or_replace(client):
|
|
131
|
+
result = client.nested.begin_create_or_replace(
|
|
132
132
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
133
133
|
top_level_tracked_resource_name="top",
|
|
134
134
|
nexted_proxy_resource_name="nested",
|
|
@@ -142,12 +142,12 @@ def test_nested_proxy_resources_begin_create_or_replace(client):
|
|
|
142
142
|
assert result.properties.description == "valid"
|
|
143
143
|
assert result.properties.provisioning_state == "Succeeded"
|
|
144
144
|
assert result.name == "nested"
|
|
145
|
-
assert result.type == "Azure.ResourceManager.
|
|
145
|
+
assert result.type == "Azure.ResourceManager.Resources/topLevelTrackedResources/top/nestedProxyResources"
|
|
146
146
|
assert result.system_data.created_by == "AzureSDK"
|
|
147
147
|
|
|
148
148
|
|
|
149
|
-
def
|
|
150
|
-
result = client.
|
|
149
|
+
def test_nested_begin_update(client):
|
|
150
|
+
result = client.nested.begin_update(
|
|
151
151
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
152
152
|
top_level_tracked_resource_name="top",
|
|
153
153
|
nexted_proxy_resource_name="nested",
|
|
@@ -161,12 +161,12 @@ def test_nested_proxy_resources_begin_update(client):
|
|
|
161
161
|
assert result.properties.description == "valid2"
|
|
162
162
|
assert result.properties.provisioning_state == "Succeeded"
|
|
163
163
|
assert result.name == "nested"
|
|
164
|
-
assert result.type == "Azure.ResourceManager.
|
|
164
|
+
assert result.type == "Azure.ResourceManager.Resources/topLevelTrackedResources/top/nestedProxyResources"
|
|
165
165
|
assert result.system_data.created_by == "AzureSDK"
|
|
166
166
|
|
|
167
167
|
|
|
168
|
-
def
|
|
169
|
-
client.
|
|
168
|
+
def test_nested_begin_delete(client):
|
|
169
|
+
client.nested.begin_delete(
|
|
170
170
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
171
171
|
top_level_tracked_resource_name="top",
|
|
172
172
|
nexted_proxy_resource_name="nested",
|
|
@@ -174,8 +174,8 @@ def test_nested_proxy_resources_begin_delete(client):
|
|
|
174
174
|
).result()
|
|
175
175
|
|
|
176
176
|
|
|
177
|
-
def
|
|
178
|
-
response = client.
|
|
177
|
+
def test_nested_list_by_top_level_tracked_resource(client):
|
|
178
|
+
response = client.nested.list_by_top_level_tracked_resource(
|
|
179
179
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
180
180
|
top_level_tracked_resource_name="top",
|
|
181
181
|
)
|
|
@@ -184,31 +184,31 @@ def test_nested_proxy_resources_list_by_top_level_tracked_resource(client):
|
|
|
184
184
|
assert result.properties.description == "valid"
|
|
185
185
|
assert result.properties.provisioning_state == "Succeeded"
|
|
186
186
|
assert result.name == "nested"
|
|
187
|
-
assert result.type == "Azure.ResourceManager.
|
|
187
|
+
assert result.type == "Azure.ResourceManager.Resources/topLevelTrackedResources/top/nestedProxyResources"
|
|
188
188
|
assert result.system_data.created_by == "AzureSDK"
|
|
189
189
|
|
|
190
190
|
|
|
191
|
-
def
|
|
192
|
-
client.
|
|
191
|
+
def test_top_level_action_sync(client):
|
|
192
|
+
client.top_level.action_sync(
|
|
193
193
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
194
194
|
top_level_tracked_resource_name="top",
|
|
195
195
|
body={"message": "Resource action at top level.", "urgent": True},
|
|
196
196
|
)
|
|
197
197
|
|
|
198
198
|
|
|
199
|
-
def
|
|
200
|
-
result = client.
|
|
199
|
+
def test_singleton_get_by_resource_group(client):
|
|
200
|
+
result = client.singleton.get_by_resource_group(
|
|
201
201
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
202
202
|
)
|
|
203
203
|
assert result.properties.description == "valid"
|
|
204
204
|
assert result.properties.provisioning_state == "Succeeded"
|
|
205
205
|
assert result.name == "default"
|
|
206
|
-
assert result.type == "Azure.ResourceManager.
|
|
206
|
+
assert result.type == "Azure.ResourceManager.Resources/singletonTrackedResources"
|
|
207
207
|
assert result.system_data.created_by == "AzureSDK"
|
|
208
208
|
|
|
209
209
|
|
|
210
|
-
def
|
|
211
|
-
result = client.
|
|
210
|
+
def test_singleton_begin_create_or_replace(client):
|
|
211
|
+
result = client.singleton.begin_create_or_update(
|
|
212
212
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
213
213
|
resource=models.SingletonTrackedResource(
|
|
214
214
|
location="eastus",
|
|
@@ -220,12 +220,12 @@ def test_singleton_tracked_resources_begin_create_or_replace(client):
|
|
|
220
220
|
assert result.properties.description == "valid"
|
|
221
221
|
assert result.properties.provisioning_state == "Succeeded"
|
|
222
222
|
assert result.name == "default"
|
|
223
|
-
assert result.type == "Azure.ResourceManager.
|
|
223
|
+
assert result.type == "Azure.ResourceManager.Resources/singletonTrackedResources"
|
|
224
224
|
assert result.system_data.created_by == "AzureSDK"
|
|
225
225
|
|
|
226
226
|
|
|
227
|
-
def
|
|
228
|
-
result = client.
|
|
227
|
+
def test_singleton_update(client):
|
|
228
|
+
result = client.singleton.update(
|
|
229
229
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
230
230
|
properties=models.SingletonTrackedResource(
|
|
231
231
|
location="eastus2",
|
|
@@ -237,12 +237,12 @@ def test_singleton_tracked_resources_update(client):
|
|
|
237
237
|
assert result.properties.description == "valid2"
|
|
238
238
|
assert result.properties.provisioning_state == "Succeeded"
|
|
239
239
|
assert result.name == "default"
|
|
240
|
-
assert result.type == "Azure.ResourceManager.
|
|
240
|
+
assert result.type == "Azure.ResourceManager.Resources/singletonTrackedResources"
|
|
241
241
|
assert result.system_data.created_by == "AzureSDK"
|
|
242
242
|
|
|
243
243
|
|
|
244
|
-
def
|
|
245
|
-
response = client.
|
|
244
|
+
def test_singleton_list_by_resource_group(client):
|
|
245
|
+
response = client.singleton.list_by_resource_group(
|
|
246
246
|
resource_group_name=RESOURCE_GROUP_NAME,
|
|
247
247
|
)
|
|
248
248
|
result = [r for r in response]
|
|
@@ -250,5 +250,5 @@ def test_singleton_tracked_resources_list_by_resource_group(client):
|
|
|
250
250
|
assert result.properties.description == "valid"
|
|
251
251
|
assert result.properties.provisioning_state == "Succeeded"
|
|
252
252
|
assert result.name == "default"
|
|
253
|
-
assert result.type == "Azure.ResourceManager.
|
|
253
|
+
assert result.type == "Azure.ResourceManager.Resources/singletonTrackedResources"
|
|
254
254
|
assert result.system_data.created_by == "AzureSDK"
|
|
@@ -15,60 +15,60 @@ def client():
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def test_no_decorator_in_public(client: AccessClient):
|
|
18
|
-
result = client.public_operation.no_decorator_in_public(name="
|
|
19
|
-
assert result == models.NoDecoratorModelInPublic(name="
|
|
18
|
+
result = client.public_operation.no_decorator_in_public(name="sample")
|
|
19
|
+
assert result == models.NoDecoratorModelInPublic(name="sample")
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def test_public_decorator_in_public(client: AccessClient):
|
|
23
|
-
result = client.public_operation.public_decorator_in_public(name="
|
|
24
|
-
assert result == models.PublicDecoratorModelInPublic(name="
|
|
23
|
+
result = client.public_operation.public_decorator_in_public(name="sample")
|
|
24
|
+
assert result == models.PublicDecoratorModelInPublic(name="sample")
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def test_no_decorator_in_internal(client: AccessClient):
|
|
28
|
-
result = client.internal_operation._no_decorator_in_internal(name="
|
|
29
|
-
assert result == models._models.NoDecoratorModelInInternal(name="
|
|
28
|
+
result = client.internal_operation._no_decorator_in_internal(name="sample")
|
|
29
|
+
assert result == models._models.NoDecoratorModelInInternal(name="sample")
|
|
30
30
|
|
|
31
31
|
with pytest.raises(ImportError):
|
|
32
32
|
from specs.azure.clientgenerator.core.access.models import NoDecoratorModelInInternal
|
|
33
33
|
|
|
34
34
|
with pytest.raises(AttributeError):
|
|
35
|
-
client.internal_operation.no_decorator_in_internal(name="
|
|
35
|
+
client.internal_operation.no_decorator_in_internal(name="sample")
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
def test_internal_decorator_in_internal(client: AccessClient):
|
|
39
|
-
result = client.internal_operation._internal_decorator_in_internal(name="
|
|
40
|
-
assert result == models._models.InternalDecoratorModelInInternal(name="
|
|
39
|
+
result = client.internal_operation._internal_decorator_in_internal(name="sample")
|
|
40
|
+
assert result == models._models.InternalDecoratorModelInInternal(name="sample")
|
|
41
41
|
|
|
42
42
|
with pytest.raises(ImportError):
|
|
43
43
|
from specs.azure.clientgenerator.core.access.models import InternalDecoratorModelInInternal
|
|
44
44
|
|
|
45
45
|
with pytest.raises(AttributeError):
|
|
46
|
-
client.internal_operation.internal_decorator_in_internal(name="
|
|
46
|
+
client.internal_operation.internal_decorator_in_internal(name="sample")
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
def test_public_decorator_in_internal(client: AccessClient):
|
|
50
|
-
result = client.internal_operation._public_decorator_in_internal(name="
|
|
51
|
-
assert result == models.PublicDecoratorModelInInternal(name="
|
|
50
|
+
result = client.internal_operation._public_decorator_in_internal(name="sample")
|
|
51
|
+
assert result == models.PublicDecoratorModelInInternal(name="sample")
|
|
52
52
|
|
|
53
53
|
with pytest.raises(AttributeError):
|
|
54
|
-
client.internal_operation.public_decorator_in_internal(name="
|
|
54
|
+
client.internal_operation.public_decorator_in_internal(name="sample")
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
def test_public(client: AccessClient):
|
|
58
|
-
result = client.shared_model_in_operation.public(name="
|
|
59
|
-
assert result == models.SharedModel(name="
|
|
58
|
+
result = client.shared_model_in_operation.public(name="sample")
|
|
59
|
+
assert result == models.SharedModel(name="sample")
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
def test_internal(client: AccessClient):
|
|
63
|
-
result = client.shared_model_in_operation._internal(name="
|
|
64
|
-
assert result == models.SharedModel(name="
|
|
63
|
+
result = client.shared_model_in_operation._internal(name="sample")
|
|
64
|
+
assert result == models.SharedModel(name="sample")
|
|
65
65
|
|
|
66
66
|
with pytest.raises(AttributeError):
|
|
67
|
-
client.shared_model_in_operation.internal(name="
|
|
67
|
+
client.shared_model_in_operation.internal(name="sample")
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
def test_operation(client: AccessClient):
|
|
71
|
-
result = client.relative_model_in_operation._operation(name="
|
|
71
|
+
result = client.relative_model_in_operation._operation(name="Madge")
|
|
72
72
|
assert result == models._models.OuterModel(name="Madge", inner=models._models.InnerModel(name="Madge"))
|
|
73
73
|
|
|
74
74
|
with pytest.raises(ImportError):
|
|
@@ -78,7 +78,7 @@ def test_operation(client: AccessClient):
|
|
|
78
78
|
from specs.azure.clientgenerator.core.access.models import InnerModel
|
|
79
79
|
|
|
80
80
|
with pytest.raises(AttributeError):
|
|
81
|
-
client.shared_model_in_operation.operation(name="
|
|
81
|
+
client.shared_model_in_operation.operation(name="sample")
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
def test_discriminator(client: AccessClient):
|
|
@@ -22,8 +22,8 @@ mypy==1.10.1
|
|
|
22
22
|
-e ./generated/azure-core-page
|
|
23
23
|
-e ./generated/azure-special-headers-client-request-id/
|
|
24
24
|
-e ./generated/azure-example-basic
|
|
25
|
-
-e ./generated/azure-resource-manager-
|
|
26
|
-
-e ./generated/azure-resource-manager-
|
|
25
|
+
-e ./generated/azure-resource-manager-common-properties
|
|
26
|
+
-e ./generated/azure-resource-manager-resources
|
|
27
27
|
|
|
28
28
|
# common test case
|
|
29
29
|
-e ./generated/authentication-api-key
|
|
@@ -17,8 +17,8 @@ from authentication.union.aio import UnionClient
|
|
|
17
17
|
async def api_key_client(key_credential):
|
|
18
18
|
client = None
|
|
19
19
|
|
|
20
|
-
def _build_client(client_type):
|
|
21
|
-
client = client_type(key_credential(
|
|
20
|
+
def _build_client(client_type, key: str = "valid-key"):
|
|
21
|
+
client = client_type(key_credential(key))
|
|
22
22
|
return client
|
|
23
23
|
|
|
24
24
|
yield _build_client
|
|
@@ -53,8 +53,8 @@ async def oauth2_client(token_credential):
|
|
|
53
53
|
async def http_custom_client(key_credential):
|
|
54
54
|
client = None
|
|
55
55
|
|
|
56
|
-
def _build_client():
|
|
57
|
-
client = CustomClient(key_credential(
|
|
56
|
+
def _build_client(key: str = "valid-key"):
|
|
57
|
+
client = CustomClient(key_credential(key))
|
|
58
58
|
return client
|
|
59
59
|
|
|
60
60
|
yield _build_client
|
|
@@ -73,7 +73,7 @@ async def test_api_key_valid(api_key_client):
|
|
|
73
73
|
|
|
74
74
|
@pytest.mark.asyncio
|
|
75
75
|
async def test_api_key_invalid(api_key_client, core_library):
|
|
76
|
-
client = api_key_client(ApiKeyClient)
|
|
76
|
+
client = api_key_client(ApiKeyClient, "invalid-key")
|
|
77
77
|
with pytest.raises(core_library.exceptions.HttpResponseError) as ex:
|
|
78
78
|
await client.invalid()
|
|
79
79
|
assert ex.value.status_code == 403
|
|
@@ -114,7 +114,7 @@ async def test_http_custom_valid(http_custom_client):
|
|
|
114
114
|
|
|
115
115
|
@pytest.mark.asyncio
|
|
116
116
|
async def test_http_custom_invalid(http_custom_client, core_library):
|
|
117
|
-
client = http_custom_client()
|
|
117
|
+
client = http_custom_client(key="invalid-key")
|
|
118
118
|
with pytest.raises(core_library.exceptions.HttpResponseError) as ex:
|
|
119
119
|
await client.invalid()
|
|
120
120
|
assert ex.value.status_code == 403
|
|
@@ -17,8 +17,8 @@ from authentication.http.custom import CustomClient
|
|
|
17
17
|
def api_key_client(key_credential):
|
|
18
18
|
client = None
|
|
19
19
|
|
|
20
|
-
def _build_client(client_type):
|
|
21
|
-
client = client_type(key_credential(
|
|
20
|
+
def _build_client(client_type, key: str = "valid-key"):
|
|
21
|
+
client = client_type(key_credential(key))
|
|
22
22
|
return client
|
|
23
23
|
|
|
24
24
|
yield _build_client
|
|
@@ -53,8 +53,8 @@ def oauth2_client(token_credential):
|
|
|
53
53
|
def http_custom_client(key_credential):
|
|
54
54
|
client = None
|
|
55
55
|
|
|
56
|
-
def _build_client():
|
|
57
|
-
client = CustomClient(key_credential(
|
|
56
|
+
def _build_client(key: str = "valid-key"):
|
|
57
|
+
client = CustomClient(key_credential(key))
|
|
58
58
|
return client
|
|
59
59
|
|
|
60
60
|
yield _build_client
|
|
@@ -71,7 +71,7 @@ def test_api_key_valid(api_key_client):
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
def test_api_key_invalid(api_key_client, core_library):
|
|
74
|
-
client = api_key_client(ApiKeyClient)
|
|
74
|
+
client = api_key_client(ApiKeyClient, "invalid-key")
|
|
75
75
|
with pytest.raises(core_library.exceptions.HttpResponseError) as ex:
|
|
76
76
|
client.invalid()
|
|
77
77
|
assert ex.value.status_code == 403
|
|
@@ -106,7 +106,7 @@ def test_http_custom_valid(http_custom_client):
|
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
def test_http_custom_invalid(http_custom_client, core_library):
|
|
109
|
-
client = http_custom_client()
|
|
109
|
+
client = http_custom_client("invalid-key")
|
|
110
110
|
with pytest.raises(core_library.exceptions.HttpResponseError) as ex:
|
|
111
111
|
client.invalid()
|
|
112
112
|
assert ex.value.status_code == 403
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-client-python",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec emitter for Python SDKs",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@azure-tools/typespec-azure-core": ">=0.47.0 <1.0.0",
|
|
55
55
|
"@azure-tools/typespec-azure-resource-manager": ">=0.47.0 <1.0.0",
|
|
56
56
|
"@azure-tools/typespec-autorest": ">=0.47.0 <1.0.0",
|
|
57
|
-
"@azure-tools/typespec-client-generator-core": ">=0.47.
|
|
57
|
+
"@azure-tools/typespec-client-generator-core": ">=0.47.4 <1.0.0",
|
|
58
58
|
"@azure-tools/typespec-azure-rulesets": ">=0.47.0 <3.0.0",
|
|
59
59
|
"@typespec/compiler": ">=0.61.0 <1.0.0",
|
|
60
60
|
"@typespec/http": ">=0.61.0 <1.0.0",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@azure-tools/typespec-azure-resource-manager": "~0.47.0",
|
|
71
71
|
"@azure-tools/typespec-autorest": "~0.47.0",
|
|
72
|
-
"@azure-tools/cadl-ranch-expect": "0.15.5",
|
|
73
|
-
"@azure-tools/cadl-ranch-specs": "0.
|
|
72
|
+
"@azure-tools/cadl-ranch-expect": "~0.15.5",
|
|
73
|
+
"@azure-tools/cadl-ranch-specs": "~0.39.0",
|
|
74
74
|
"@types/js-yaml": "~4.0.5",
|
|
75
75
|
"@types/node": "~22.5.4",
|
|
76
76
|
"@types/semver": "7.5.8",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"typescript": "~5.6.2",
|
|
81
81
|
"typescript-eslint": "^8.5.0",
|
|
82
82
|
"@azure-tools/typespec-azure-core": "~0.47.0",
|
|
83
|
-
"@azure-tools/typespec-client-generator-core": "~0.47.
|
|
83
|
+
"@azure-tools/typespec-client-generator-core": "~0.47.4",
|
|
84
84
|
"@typespec/compiler": "~0.61.0",
|
|
85
85
|
"@typespec/http": "~0.61.0",
|
|
86
86
|
"@typespec/rest": "~0.61.0",
|