Skip to content

Commit 561d522

Browse files
reenable tests (#20978)
1 parent 5069292 commit 561d522

14 files changed

+79
-83
lines changed

sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_base_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def __init__(self, endpoint, credential, **kwargs):
5656
"op",
5757
"pages",
5858
"readingOrder",
59+
"stringIndexType",
60+
"api-version"
5961
}
6062
)
6163

sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_base_client_async.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def __init__(
6767
"op",
6868
"pages",
6969
"readingOrder",
70+
"stringIndexType",
71+
"api-version"
7072
}
7173
)
7274
self._client = FormRecognizer(

sdk/formrecognizer/azure-ai-formrecognizer/tests/recordings/test_receipt.test_receipt_locale_error.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,31 @@ interactions:
1212
Content-Length:
1313
- '154512'
1414
Content-Type:
15-
- image/jpeg
15+
- application/octet-stream
1616
User-Agent:
17-
- azsdk-python-ai-formrecognizer/3.2.0b1 Python/3.9.1 (Windows-10-10.0.19041-SP0)
17+
- azsdk-python-ai-formrecognizer/3.2.0b1 Python/3.9.0 (Windows-10-10.0.19041-SP0)
1818
method: POST
19-
uri: https://region.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/receipt/analyze?includeTextDetails=false&locale=not%20a%20locale
19+
uri: https://region.api.cognitive.microsoft.com/formrecognizer/documentModels/prebuilt-receipt:analyze?locale=not%20a%20locale&stringIndexType=unicodeCodePoint&api-version=2021-09-30-preview
2020
response:
2121
body:
22-
string: '{"error": {"code": "UnsupportedLocale", "innerError": {"requestId":
23-
"c6836b61-db64-4355-8b25-e1948f564d44"}, "message": "Locale unsupported. Supported
24-
locales include en-AU, en-CA, en-GB, en-IN and en-US."}}'
22+
string: '{"error": {"code": "InvalidArgument", "message": "Invalid argument.",
23+
"innererror": {"code": "InvalidParameter", "message": "The parameter Locale
24+
is invalid: The language code is invalid or not supported."}}}'
2525
headers:
2626
apim-request-id:
27-
- c6836b61-db64-4355-8b25-e1948f564d44
28-
content-length:
29-
- '200'
27+
- edf133b9-e46e-458e-a38e-3a148a6ed1f2
3028
content-type:
3129
- application/json; charset=utf-8
3230
date:
33-
- Mon, 30 Aug 2021 23:48:59 GMT
31+
- Thu, 30 Sep 2021 17:06:02 GMT
3432
strict-transport-security:
3533
- max-age=31536000; includeSubDomains; preload
34+
transfer-encoding:
35+
- chunked
3636
x-content-type-options:
3737
- nosniff
3838
x-envoy-upstream-service-time:
39-
- '113'
39+
- '135'
4040
status:
4141
code: 400
4242
message: Bad Request

sdk/formrecognizer/azure-ai-formrecognizer/tests/recordings/test_receipt_async.test_receipt_locale_error.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ interactions:
66
Accept:
77
- application/json
88
Content-Type:
9-
- image/jpeg
9+
- application/octet-stream
1010
User-Agent:
11-
- azsdk-python-ai-formrecognizer/3.1.0 Python/3.9.0 (Windows-10-10.0.19041-SP0)
11+
- azsdk-python-ai-formrecognizer/3.2.0b1 Python/3.9.0 (Windows-10-10.0.19041-SP0)
1212
method: POST
13-
uri: https://region.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/receipt/analyze?includeTextDetails=false&locale=not%20a%20locale
13+
uri: https://region.api.cognitive.microsoft.com/formrecognizer/documentModels/prebuilt-receipt:analyze?locale=not%20a%20locale&stringIndexType=unicodeCodePoint&api-version=2021-09-30-preview
1414
response:
1515
body:
16-
string: '{"error": {"code": "UnsupportedLocale", "innerError": {"requestId":
17-
"4c27b38d-d0e4-4b41-b76a-0422a7b924b9"}, "message": "Locale unsupported. Supported
18-
locales include en-AU, en-CA, en-GB, en-IN and en-US."}}'
16+
string: '{"error": {"code": "InvalidArgument", "message": "Invalid argument.",
17+
"innererror": {"code": "InvalidParameter", "message": "The parameter Locale
18+
is invalid: The language code is invalid or not supported."}}}'
1919
headers:
20-
apim-request-id: 4c27b38d-d0e4-4b41-b76a-0422a7b924b9
21-
content-length: '200'
20+
apim-request-id: 8f6bc0ec-dfbe-4d03-895f-b0cf4bec6192
2221
content-type: application/json; charset=utf-8
23-
date: Tue, 11 May 2021 03:08:08 GMT
22+
date: Thu, 30 Sep 2021 17:06:19 GMT
2423
strict-transport-security: max-age=31536000; includeSubDomains; preload
24+
transfer-encoding: chunked
2525
x-content-type-options: nosniff
26-
x-envoy-upstream-service-time: '134'
26+
x-envoy-upstream-service-time: '69'
2727
status:
2828
code: 400
2929
message: Bad Request
30-
url: https://region.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/receipt/analyze?includeTextDetails=false&locale=not%20a%20locale
30+
url: https://region.api.cognitive.microsoft.com/formrecognizer/documentModels/prebuilt-receipt:analyze?locale=not%20a%20locale&stringIndexType=unicodeCodePoint&api-version=2021-09-30-preview
3131
version: 1

sdk/formrecognizer/azure-ai-formrecognizer/tests/recordings/test_receipt_from_url.test_receipt_locale_error.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interactions:
22
- request:
3-
body: 'b''{"source": "blob_sas_url"}'''
3+
body: 'b''{"urlSource": "blob_sas_url"}'''
44
headers:
55
Accept:
66
- application/json
@@ -9,33 +9,33 @@ interactions:
99
Connection:
1010
- keep-alive
1111
Content-Length:
12-
- '221'
12+
- '224'
1313
Content-Type:
1414
- application/json
1515
User-Agent:
16-
- azsdk-python-ai-formrecognizer/3.1.0 Python/3.9.0 (Windows-10-10.0.19041-SP0)
16+
- azsdk-python-ai-formrecognizer/3.2.0b1 Python/3.9.0 (Windows-10-10.0.19041-SP0)
1717
method: POST
18-
uri: https://region.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/receipt/analyze?includeTextDetails=false&locale=not%20a%20locale
18+
uri: https://region.api.cognitive.microsoft.com/formrecognizer/documentModels/prebuilt-receipt:analyze?locale=not%20a%20locale&stringIndexType=unicodeCodePoint&api-version=2021-09-30-preview
1919
response:
2020
body:
21-
string: '{"error": {"code": "UnsupportedLocale", "innerError": {"requestId":
22-
"04a5530c-7246-4327-9661-6579f4ac252b"}, "message": "Locale unsupported. Supported
23-
locales include en-AU, en-CA, en-GB, en-IN and en-US."}}'
21+
string: '{"error": {"code": "InvalidArgument", "message": "Invalid argument.",
22+
"innererror": {"code": "InvalidParameter", "message": "The parameter Locale
23+
is invalid: The language code is invalid or not supported."}}}'
2424
headers:
2525
apim-request-id:
26-
- 04a5530c-7246-4327-9661-6579f4ac252b
27-
content-length:
28-
- '200'
26+
- 37eba60a-f330-4c8f-94cf-8747ba3c2fc5
2927
content-type:
3028
- application/json; charset=utf-8
3129
date:
32-
- Tue, 11 May 2021 03:09:31 GMT
30+
- Thu, 30 Sep 2021 17:05:04 GMT
3331
strict-transport-security:
3432
- max-age=31536000; includeSubDomains; preload
33+
transfer-encoding:
34+
- chunked
3535
x-content-type-options:
3636
- nosniff
3737
x-envoy-upstream-service-time:
38-
- '289'
38+
- '564'
3939
status:
4040
code: 400
4141
message: Bad Request
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
interactions:
22
- request:
3-
body: 'b''{"source": "blob_sas_url"}'''
3+
body: 'b''{"urlSource": "blob_sas_url"}'''
44
headers:
55
Accept:
66
- application/json
77
Content-Length:
8-
- '221'
8+
- '224'
99
Content-Type:
1010
- application/json
1111
User-Agent:
12-
- azsdk-python-ai-formrecognizer/3.1.0 Python/3.9.0 (Windows-10-10.0.19041-SP0)
12+
- azsdk-python-ai-formrecognizer/3.2.0b1 Python/3.9.0 (Windows-10-10.0.19041-SP0)
1313
method: POST
14-
uri: https://region.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/receipt/analyze?includeTextDetails=false&locale=not%20a%20locale
14+
uri: https://region.api.cognitive.microsoft.com/formrecognizer/documentModels/prebuilt-receipt:analyze?locale=not%20a%20locale&stringIndexType=unicodeCodePoint&api-version=2021-09-30-preview
1515
response:
1616
body:
17-
string: '{"error": {"code": "UnsupportedLocale", "innerError": {"requestId":
18-
"c72b100e-f260-4bd3-874f-3354e1b08e83"}, "message": "Locale unsupported. Supported
19-
locales include en-AU, en-CA, en-GB, en-IN and en-US."}}'
17+
string: '{"error": {"code": "InvalidArgument", "message": "Invalid argument.",
18+
"innererror": {"code": "InvalidParameter", "message": "The parameter Locale
19+
is invalid: The language code is invalid or not supported."}}}'
2020
headers:
21-
apim-request-id: c72b100e-f260-4bd3-874f-3354e1b08e83
22-
content-length: '200'
21+
apim-request-id: e6c4d122-9c19-4bfb-9d69-f5914cfc29b4
2322
content-type: application/json; charset=utf-8
24-
date: Tue, 11 May 2021 03:12:51 GMT
23+
date: Thu, 30 Sep 2021 17:06:34 GMT
2524
strict-transport-security: max-age=31536000; includeSubDomains; preload
25+
transfer-encoding: chunked
2626
x-content-type-options: nosniff
27-
x-envoy-upstream-service-time: '897'
27+
x-envoy-upstream-service-time: '581'
2828
status:
2929
code: 400
3030
message: Bad Request
31-
url: https://region.api.cognitive.microsoft.com/formrecognizer/v2.1/prebuilt/receipt/analyze?includeTextDetails=false&locale=not%20a%20locale
31+
url: https://region.api.cognitive.microsoft.com/formrecognizer/documentModels/prebuilt-receipt:analyze?locale=not%20a%20locale&stringIndexType=unicodeCodePoint&api-version=2021-09-30-preview
3232
version: 1

sdk/formrecognizer/azure-ai-formrecognizer/tests/test_logging.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
except ImportError: # python < 3.3
1414
import mock # type: ignore
1515

16-
from azure.ai.formrecognizer import FormRecognizerClient, FormTrainingClient
16+
from azure.ai.formrecognizer import DocumentAnalysisClient, DocumentModelAdministrationClient
1717
from azure.core.credentials import AzureKeyCredential
1818
from azure.core.exceptions import HttpResponseError
1919
from testcase import FormRecognizerTest
@@ -27,20 +27,20 @@ def __init__(self):
2727
def emit(self, record):
2828
self.messages.append(record)
2929

30-
@pytest.mark.skip
30+
3131
class TestLogging(FormRecognizerTest):
3232

3333
@FormRecognizerPreparer()
3434
@pytest.mark.live_test_only
35-
def test_logging_info_fr_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
36-
client = FormRecognizerClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
35+
def test_logging_info_dac_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
36+
client = DocumentAnalysisClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
3737
mock_handler = MockHandler()
3838

3939
logger = logging.getLogger("azure")
4040
logger.addHandler(mock_handler)
4141
logger.setLevel(logging.INFO)
4242

43-
poller = client.begin_recognize_invoices_from_url(self.receipt_url_jpg)
43+
poller = client.begin_analyze_document_from_url("prebuilt-receipt", self.receipt_url_jpg)
4444
result = poller.result()
4545

4646
for message in mock_handler.messages:
@@ -53,15 +53,15 @@ def test_logging_info_fr_client(self, formrecognizer_test_endpoint, formrecogniz
5353

5454
@FormRecognizerPreparer()
5555
@pytest.mark.live_test_only
56-
def test_logging_info_ft_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
57-
client = FormTrainingClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
56+
def test_logging_info_dmac_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
57+
client = DocumentModelAdministrationClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
5858
mock_handler = MockHandler()
5959

6060
logger = logging.getLogger("azure")
6161
logger.addHandler(mock_handler)
6262
logger.setLevel(logging.INFO)
6363

64-
result = client.get_account_properties()
64+
result = client.get_account_info()
6565

6666
for message in mock_handler.messages:
6767
if message.levelname == "INFO":
@@ -86,10 +86,10 @@ def test_mock_quota_exceeded_403(self, formrecognizer_test_endpoint, formrecogni
8686
response.content_type = "application/json"
8787
transport = mock.Mock(send=lambda request, **kwargs: response)
8888

89-
client = FormRecognizerClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key), transport=transport)
89+
client = DocumentAnalysisClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key), transport=transport)
9090

9191
with pytest.raises(HttpResponseError) as e:
92-
poller = client.begin_recognize_receipts_from_url(self.receipt_url_jpg)
92+
poller = client.begin_analyze_document_from_url("prebuilt-receipt", self.receipt_url_jpg)
9393
assert e.value.status_code == 403
9494
assert e.value.error.message == 'Out of call volume quota for FormRecognizer F0 pricing tier. Please retry after 1 day. To increase your call volume switch to a paid tier.'
9595

@@ -108,9 +108,9 @@ def test_mock_quota_exceeded_429(self, formrecognizer_test_endpoint, formrecogni
108108
response.content_type = "application/json"
109109
transport = mock.Mock(send=lambda request, **kwargs: response)
110110

111-
client = FormRecognizerClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key), transport=transport)
111+
client = DocumentAnalysisClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key), transport=transport)
112112

113113
with pytest.raises(HttpResponseError) as e:
114-
poller = client.begin_recognize_receipts_from_url(self.receipt_url_jpg)
114+
poller = client.begin_analyze_document_from_url("prebuilt-receipt", self.receipt_url_jpg)
115115
assert e.value.status_code == 429
116116
assert e.value.error.message == 'Out of call volume quota for FormRecognizer F0 pricing tier. Please retry after 1 day. To increase your call volume switch to a paid tier.'

sdk/formrecognizer/azure-ai-formrecognizer/tests/test_logging_async.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from unittest import mock
1616
except ImportError: # python < 3.3
1717
import mock # type: ignore
18-
from azure.ai.formrecognizer.aio import FormRecognizerClient, FormTrainingClient
18+
from azure.ai.formrecognizer.aio import DocumentAnalysisClient, DocumentModelAdministrationClient
1919
from azure.core.credentials import AzureKeyCredential
2020
from azure.core.exceptions import HttpResponseError
2121
from preparers import FormRecognizerPreparer
@@ -62,20 +62,20 @@ def __init__(self, *args, **kwargs):
6262
self.__aenter__ = mock.Mock(return_value=get_completed_future())
6363
self.__aexit__ = mock.Mock(return_value=get_completed_future())
6464

65-
@pytest.mark.skip
65+
6666
class TestLogging(AsyncFormRecognizerTest):
6767

6868
@FormRecognizerPreparer()
6969
@pytest.mark.live_test_only
70-
async def test_logging_info_fr_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
71-
client = FormRecognizerClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
70+
async def test_logging_info_dac_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
71+
client = DocumentAnalysisClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
7272
mock_handler = MockHandler()
7373

7474
logger = logging.getLogger("azure")
7575
logger.addHandler(mock_handler)
7676
logger.setLevel(logging.INFO)
7777
async with client:
78-
poller = await client.begin_recognize_invoices_from_url(self.receipt_url_jpg)
78+
poller = await client.begin_analyze_document_from_url("prebuilt-receipt", self.receipt_url_jpg)
7979
result = await poller.result()
8080

8181
for message in mock_handler.messages:
@@ -88,15 +88,15 @@ async def test_logging_info_fr_client(self, formrecognizer_test_endpoint, formre
8888

8989
@FormRecognizerPreparer()
9090
@pytest.mark.live_test_only
91-
async def test_logging_info_ft_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
92-
client = FormTrainingClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
91+
async def test_logging_info_dmac_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
92+
client = DocumentModelAdministrationClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
9393
mock_handler = MockHandler()
9494

9595
logger = logging.getLogger("azure")
9696
logger.addHandler(mock_handler)
9797
logger.setLevel(logging.INFO)
9898
async with client:
99-
result = await client.get_account_properties()
99+
result = await client.get_account_info()
100100

101101
for message in mock_handler.messages:
102102
if message.levelname == "INFO":
@@ -121,10 +121,10 @@ async def test_mock_quota_exceeded_403(self, formrecognizer_test_endpoint, formr
121121
response.content_type = "application/json"
122122
transport = AsyncMockTransport(send=wrap_in_future(lambda request, **kwargs: response))
123123

124-
client = FormRecognizerClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key), transport=transport)
124+
client = DocumentAnalysisClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key), transport=transport)
125125

126126
with pytest.raises(HttpResponseError) as e:
127-
poller = await client.begin_recognize_receipts_from_url(self.receipt_url_jpg)
127+
poller = await client.begin_analyze_document_from_url("prebuilt-receipt", self.receipt_url_jpg)
128128
assert e.value.status_code == 403
129129
assert e.value.error.message == 'Out of call volume quota for FormRecognizer F0 pricing tier. Please retry after 1 day. To increase your call volume switch to a paid tier.'
130130

@@ -142,8 +142,8 @@ async def test_mock_quota_exceeded_429(self, formrecognizer_test_endpoint, formr
142142
response.content_type = "application/json"
143143
transport = AsyncMockTransport(send=wrap_in_future(lambda request, **kwargs: response))
144144

145-
client = FormRecognizerClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key), transport=transport)
145+
client = DocumentAnalysisClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key), transport=transport)
146146
with pytest.raises(HttpResponseError) as e:
147-
poller = await client.begin_recognize_receipts_from_url(self.receipt_url_jpg)
147+
poller = await client.begin_analyze_document_from_url("prebuilt-receipt", self.receipt_url_jpg)
148148
assert e.value.status_code == 429
149-
assert e.value.error.message == 'Out of call volume quota for FormRecognizer F0 pricing tier. Please retry after 1 day. To increase your call volume switch to a paid tier.'
149+
assert e.value.error.message == 'Out of call volume quota for FormRecognizer F0 pricing tier. Please retry after 1 day. To increase your call volume switch to a paid tier.'

sdk/formrecognizer/azure-ai-formrecognizer/tests/test_mgmt.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
class TestManagement(FormRecognizerTest):
2929

30-
@pytest.mark.skip("aad not working in canary")
3130
@FormRecognizerPreparer()
3231
@pytest.mark.live_test_only
3332
def test_active_directory_auth(self):

sdk/formrecognizer/azure-ai-formrecognizer/tests/test_mgmt_async.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
class TestManagementAsync(AsyncFormRecognizerTest):
3131

32-
@pytest.mark.skip("no aad yet in private preview")
3332
@FormRecognizerPreparer()
3433
@pytest.mark.live_test_only
3534
async def test_active_directory_auth_async(self):

0 commit comments

Comments
 (0)