Skip to content

Commit bf38f4e

Browse files
Yalin Lil0lawrence
authored andcommitted
[DI] Enable skipped tests (Azure#37732)
1 parent 9514375 commit bf38f4e

File tree

5 files changed

+135
-10
lines changed

5 files changed

+135
-10
lines changed

sdk/documentintelligence/azure-ai-documentintelligence/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/documentintelligence/azure-ai-documentintelligence",
5-
"Tag": "python/documentintelligence/azure-ai-documentintelligence_c952134951"
5+
"Tag": "python/documentintelligence/azure-ai-documentintelligence_a520415df9"
66
}

sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/_operations/_patch.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,70 @@ def get_long_running_output(pipeline_response):
327327
self._client, raw_result, get_long_running_output, polling_method # type: ignore
328328
)
329329

330+
@distributed_trace
331+
def begin_copy_classifier_to(
332+
self,
333+
classifier_id: str,
334+
copy_to_request: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]],
335+
**kwargs: Any,
336+
) -> LROPoller[_models.DocumentClassifierDetails]:
337+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
338+
_params = kwargs.pop("params", {}) or {}
339+
340+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
341+
cls: ClsType[_models.DocumentClassifierDetails] = kwargs.pop("cls", None)
342+
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
343+
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
344+
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
345+
if cont_token is None:
346+
raw_result = self._copy_classifier_to_initial(
347+
classifier_id=classifier_id,
348+
copy_to_request=copy_to_request,
349+
content_type=content_type,
350+
cls=lambda x, y, z: x,
351+
headers=_headers,
352+
params=_params,
353+
**kwargs,
354+
)
355+
raw_result.http_response.read() # type: ignore
356+
kwargs.pop("error_map", None)
357+
358+
def get_long_running_output(pipeline_response):
359+
response_headers = {}
360+
response = pipeline_response.http_response
361+
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
362+
response_headers["Operation-Location"] = self._deserialize(
363+
"str", response.headers.get("Operation-Location")
364+
)
365+
366+
deserialized = _deserialize(_models.DocumentClassifierDetails, response.json())
367+
if cls:
368+
return cls(pipeline_response, deserialized, response_headers) # type: ignore
369+
return deserialized
370+
371+
path_format_arguments = {
372+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
373+
}
374+
375+
if polling is True:
376+
polling_method: PollingMethod = cast(
377+
PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs)
378+
)
379+
elif polling is False:
380+
polling_method = cast(PollingMethod, NoPolling())
381+
else:
382+
polling_method = polling
383+
if cont_token:
384+
return LROPoller[_models.DocumentClassifierDetails].from_continuation_token(
385+
polling_method=polling_method,
386+
continuation_token=cont_token,
387+
client=self._client,
388+
deserialization_callback=get_long_running_output,
389+
)
390+
return LROPoller[_models.DocumentClassifierDetails](
391+
self._client, raw_result, get_long_running_output, polling_method # type: ignore
392+
)
393+
330394

331395
class DocumentIntelligenceClientOperationsMixin(GeneratedDIClientOps): # pylint: disable=name-too-long
332396
@overload

sdk/documentintelligence/azure-ai-documentintelligence/azure/ai/documentintelligence/aio/_operations/_patch.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,71 @@ def get_long_running_output(pipeline_response):
318318
self._client, raw_result, get_long_running_output, polling_method # type: ignore
319319
)
320320

321+
@distributed_trace_async
322+
async def begin_copy_classifier_to( # type: ignore[override]
323+
self,
324+
classifier_id: str,
325+
copy_to_request: Union[_models.ClassifierCopyAuthorization, JSON, IO[bytes]],
326+
**kwargs: Any
327+
) -> AsyncLROPoller[_models.DocumentClassifierDetails]:
328+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
329+
_params = kwargs.pop("params", {}) or {}
330+
331+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
332+
cls: ClsType[_models.DocumentClassifierDetails] = kwargs.pop("cls", None)
333+
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
334+
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
335+
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
336+
if cont_token is None:
337+
raw_result = await self._copy_classifier_to_initial(
338+
classifier_id=classifier_id,
339+
copy_to_request=copy_to_request,
340+
content_type=content_type,
341+
cls=lambda x, y, z: x,
342+
headers=_headers,
343+
params=_params,
344+
**kwargs
345+
)
346+
await raw_result.http_response.read() # type: ignore
347+
kwargs.pop("error_map", None)
348+
349+
def get_long_running_output(pipeline_response):
350+
response_headers = {}
351+
response = pipeline_response.http_response
352+
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
353+
response_headers["Operation-Location"] = self._deserialize(
354+
"str", response.headers.get("Operation-Location")
355+
)
356+
357+
deserialized = _deserialize(_models.DocumentClassifierDetails, response.json())
358+
if cls:
359+
return cls(pipeline_response, deserialized, response_headers) # type: ignore
360+
return deserialized
361+
362+
path_format_arguments = {
363+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
364+
}
365+
366+
if polling is True:
367+
polling_method: AsyncPollingMethod = cast(
368+
AsyncPollingMethod,
369+
AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs),
370+
)
371+
elif polling is False:
372+
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
373+
else:
374+
polling_method = polling
375+
if cont_token:
376+
return AsyncLROPoller[_models.DocumentClassifierDetails].from_continuation_token(
377+
polling_method=polling_method,
378+
continuation_token=cont_token,
379+
client=self._client,
380+
deserialization_callback=get_long_running_output,
381+
)
382+
return AsyncLROPoller[_models.DocumentClassifierDetails](
383+
self._client, raw_result, get_long_running_output, polling_method # type: ignore
384+
)
385+
321386

322387
class DocumentIntelligenceClientOperationsMixin(GeneratedDIClientOps): # pylint: disable=name-too-long
323388
@overload

sdk/documentintelligence/azure-ai-documentintelligence/tests/test_dmac_copy_classifier.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def test_copy_classifier_empty_classifier_id(self, **kwargs):
4242
with pytest.raises(ResourceNotFoundError):
4343
client.begin_copy_classifier_to(classifier_id="", copy_to_request={})
4444

45-
@pytest.mark.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/36989")
4645
@DocumentIntelligencePreparer()
4746
@DocumentModelAdministrationClientPreparer()
4847
@recorded_by_proxy
@@ -98,9 +97,8 @@ def test_copy_classifier_successful(self, client, documentintelligence_training_
9897
assert copy.api_version == classifier.api_version
9998
assert copy.classifier_id != classifier.classifier_id
10099
assert copy.classifier_id == copy_auth["targetClassifierId"]
100+
assert copy.base_classifier_id == classifier.base_classifier_id
101+
assert copy.base_classifier_id is None
101102
assert copy.description == classifier.description
102-
for name, doc_type in copy.doc_types.items():
103-
assert name == copy_auth["targetClassifierId"]
104-
assert doc_type.source_kind is None
105103

106104
return recorded_variables

sdk/documentintelligence/azure-ai-documentintelligence/tests/test_dmac_copy_classifier_async.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ async def test_copy_classifier_empty_classifier_id(self, **kwargs):
4343
with pytest.raises(ResourceNotFoundError):
4444
await client.begin_copy_classifier_to(classifier_id="", copy_to_request={})
4545

46-
@pytest.mark.skip(reason="https://github.com/Azure/azure-sdk-for-python/issues/36989")
4746
@DocumentIntelligencePreparer()
4847
@DocumentModelAdministrationClientPreparer()
4948
@recorded_by_proxy_async
@@ -96,14 +95,13 @@ async def test_copy_classifier_successful(
9695
)
9796
)
9897
poller = await client.begin_copy_classifier_to(classifier.classifier_id, copy_to_request=copy_auth)
99-
copy = poller.result()
98+
copy = await poller.result()
10099

101100
assert copy.api_version == classifier.api_version
102101
assert copy.classifier_id != classifier.classifier_id
103102
assert copy.classifier_id == copy_auth["targetClassifierId"]
103+
assert copy.base_classifier_id == classifier.base_classifier_id
104+
assert copy.base_classifier_id is None
104105
assert copy.description == classifier.description
105-
for name, doc_type in copy.doc_types.items():
106-
assert name == copy_auth["targetClassifierId"]
107-
assert doc_type.source_kind is None
108106

109107
return recorded_variables

0 commit comments

Comments
 (0)