Skip to content

Commit 462edaa

Browse files
[formrecognizer] Fix failing pipeline tests (Azure#23781)
* fix failing pipeline tests * set bodiless matcher * fix text proxy setting matcher live condition
1 parent ade4549 commit 462edaa

9 files changed

+436
-458
lines changed

sdk/formrecognizer/azure-ai-formrecognizer/tests/recordings/test_dac_analyze_custom_model.pyTestDACAnalyzeCustomModeltest_custom_document_signature_field.json

Lines changed: 223 additions & 227 deletions
Large diffs are not rendered by default.

sdk/formrecognizer/azure-ai-formrecognizer/tests/recordings/test_dac_analyze_custom_model_async.pyTestDACAnalyzeCustomModelAsynctest_custom_document_signature_field.json

Lines changed: 187 additions & 191 deletions
Large diffs are not rendered by default.

sdk/formrecognizer/azure-ai-formrecognizer/tests/recordings/test_dmac_training.pyTestDMACTrainingtest_build_model_azure_blob_path_filter.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,27 @@
77
"Accept": "application/json",
88
"Accept-Encoding": "gzip, deflate",
99
"Connection": "keep-alive",
10-
"Content-Length": "152",
10+
"Content-Length": "153",
1111
"Content-Type": "application/json",
12-
"User-Agent": "azsdk-python-ai-formrecognizer/3.2.0b3 Python/3.9.1 (Windows-10-10.0.19041-SP0)",
13-
"x-ms-client-request-id": "a1edbe35-7f2b-11ec-849b-c8348e073d30"
12+
"User-Agent": "azsdk-python-ai-formrecognizer/3.2.0b4 Python/3.9.1 (Windows-10-10.0.19041-SP0)"
1413
},
1514
"RequestBody": {
16-
"modelId": "3498b340-3526-4834-b00a-9eaa1ef70f19",
15+
"modelId": "a765bec0-8629-4c1d-8012-e1837cd8494a",
1716
"buildMode": "template",
1817
"azureBlobSource": {
1918
"containerUrl": "https://blob_sas_url",
20-
"prefix": "subfolder"
19+
"prefix": "testfolder"
2120
}
2221
},
2322
"StatusCode": 400,
2423
"ResponseHeaders": {
25-
"apim-request-id": "41721141-ff50-491d-84bf-3fe310ebac0a",
24+
"apim-request-id": "df890e1d-20f8-40f5-977d-4ffc40181f7c",
2625
"Content-Type": "application/json",
27-
"Date": "Thu, 27 Jan 2022 04:43:11 GMT",
26+
"Date": "Thu, 31 Mar 2022 23:41:51 GMT",
2827
"Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload",
2928
"Transfer-Encoding": "chunked",
3029
"X-Content-Type-Options": "nosniff",
31-
"x-envoy-upstream-service-time": "613"
30+
"x-envoy-upstream-service-time": "215"
3231
},
3332
"ResponseBody": {
3433
"error": {

sdk/formrecognizer/azure-ai-formrecognizer/tests/recordings/test_dmac_training_async.pyTestDMACTrainingAsynctest_build_model_azure_blob_path_filter.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,27 @@
66
"RequestHeaders": {
77
"Accept": "application/json",
88
"Accept-Encoding": "gzip, deflate",
9-
"Content-Length": "152",
9+
"Content-Length": "153",
1010
"Content-Type": "application/json",
11-
"User-Agent": "azsdk-python-ai-formrecognizer/3.2.0b3 Python/3.9.1 (Windows-10-10.0.19041-SP0)",
12-
"x-ms-client-request-id": "61720381-7f2b-11ec-9e3f-c8348e073d30"
11+
"User-Agent": "azsdk-python-ai-formrecognizer/3.2.0b4 Python/3.9.1 (Windows-10-10.0.19041-SP0)"
1312
},
1413
"RequestBody": {
15-
"modelId": "158c284d-5a3a-485b-b494-d41bfd5e8315",
14+
"modelId": "42720dcc-9c79-491b-afb0-3ee2ac20f454",
1615
"buildMode": "template",
1716
"azureBlobSource": {
1817
"containerUrl": "https://blob_sas_url",
19-
"prefix": "subfolder"
18+
"prefix": "testfolder"
2019
}
2120
},
2221
"StatusCode": 400,
2322
"ResponseHeaders": {
24-
"apim-request-id": "d5806070-92e1-48b6-bb6a-ed229b2c3aed",
23+
"apim-request-id": "289d2fb5-7e29-4e53-b5db-3fc2a61aed7f",
2524
"Content-Type": "application/json",
26-
"Date": "Thu, 27 Jan 2022 04:41:23 GMT",
25+
"Date": "Thu, 31 Mar 2022 23:41:32 GMT",
2726
"Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload",
2827
"Transfer-Encoding": "chunked",
2928
"X-Content-Type-Options": "nosniff",
30-
"x-envoy-upstream-service-time": "612"
29+
"x-envoy-upstream-service-time": "387"
3130
},
3231
"ResponseBody": {
3332
"error": {

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88
import functools
9-
from devtools_testutils import recorded_by_proxy, set_custom_default_matcher
9+
from devtools_testutils import recorded_by_proxy, set_bodiless_matcher, set_custom_default_matcher
1010
from azure.core.credentials import AzureKeyCredential
1111
from azure.ai.formrecognizer import DocumentAnalysisClient, DocumentModelAdministrationClient, AnalyzeResult
1212
from azure.ai.formrecognizer._generated.v2022_01_30_preview.models import AnalyzeResultOperation
@@ -209,10 +209,7 @@ def test_pages_kwarg_specified(self, client, formrecognizer_storage_container_sa
209209
@DocumentModelAdministrationClientPreparer()
210210
@recorded_by_proxy
211211
def test_custom_document_signature_field(self, client, formrecognizer_storage_container_sas_url, **kwargs):
212-
# this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
213-
set_custom_default_matcher(
214-
compare_bodies=False, excluded_headers="Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
215-
)
212+
set_bodiless_matcher()
216213
da_client = client.get_document_analysis_client()
217214

218215
with open(self.form_jpg, "rb") as fd:

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88
import functools
99
from devtools_testutils.aio import recorded_by_proxy_async
10-
from devtools_testutils import set_custom_default_matcher
10+
from devtools_testutils import set_bodiless_matcher, set_custom_default_matcher
1111
from azure.core.credentials import AzureKeyCredential
1212
from azure.ai.formrecognizer._generated.v2022_01_30_preview.models import AnalyzeResultOperation
1313
from azure.ai.formrecognizer.aio import DocumentAnalysisClient, DocumentModelAdministrationClient
@@ -221,10 +221,7 @@ async def test_pages_kwarg_specified(self, client, formrecognizer_storage_contai
221221
@DocumentModelAdministrationClientPreparer()
222222
@recorded_by_proxy_async
223223
async def test_custom_document_signature_field(self, client, formrecognizer_storage_container_sas_url, **kwargs):
224-
# this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
225-
set_custom_default_matcher(
226-
compare_bodies=False, excluded_headers="Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
227-
)
224+
set_bodiless_matcher()
228225
da_client = client.get_document_analysis_client()
229226

230227
with open(self.form_jpg, "rb") as fd:

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import uuid
88
import pytest
99
import functools
10-
from devtools_testutils import recorded_by_proxy, set_custom_default_matcher
10+
from devtools_testutils import recorded_by_proxy, set_bodiless_matcher, set_custom_default_matcher
1111
from azure.core.credentials import AzureKeyCredential
1212
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError
1313
from azure.ai.formrecognizer._generated.v2022_01_30_preview.models import GetOperationResponse, ModelInfo
@@ -241,12 +241,9 @@ def callback(response, _, headers):
241241
@DocumentModelAdministrationClientPreparer()
242242
@recorded_by_proxy
243243
def test_build_model_azure_blob_path_filter(self, client, formrecognizer_storage_container_sas_url, **kwargs):
244-
# this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
245-
set_custom_default_matcher(
246-
compare_bodies=False, excluded_headers="Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
247-
)
244+
set_bodiless_matcher()
248245
with pytest.raises(HttpResponseError) as e:
249-
poller = client.begin_build_model(formrecognizer_storage_container_sas_url, "template", prefix="subfolder")
246+
poller = client.begin_build_model(formrecognizer_storage_container_sas_url, "template", prefix="testfolder")
250247
model = poller.result()
251248

252249
@pytest.mark.live_test_only

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99
import functools
1010
from devtools_testutils.aio import recorded_by_proxy_async
11-
from devtools_testutils import set_custom_default_matcher
11+
from devtools_testutils import set_bodiless_matcher, set_custom_default_matcher
1212
from azure.core.credentials import AzureKeyCredential
1313
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError
1414
from azure.ai.formrecognizer._generated.v2022_01_30_preview.models import GetOperationResponse, ModelInfo
@@ -252,13 +252,10 @@ def callback(response, _, headers):
252252
@DocumentModelAdministrationClientPreparer()
253253
@recorded_by_proxy_async
254254
async def test_build_model_azure_blob_path_filter(self, client, formrecognizer_storage_container_sas_url, **kwargs):
255-
# this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
256-
set_custom_default_matcher(
257-
compare_bodies=False, excluded_headers="Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
258-
)
255+
set_bodiless_matcher()
259256
with pytest.raises(HttpResponseError) as e:
260257
async with client:
261-
poller = await client.begin_build_model(formrecognizer_storage_container_sas_url, "template", prefix="subfolder")
258+
poller = await client.begin_build_model(formrecognizer_storage_container_sas_url, "template", prefix="testfolder")
262259
model = await poller.result()
263260

264261
@pytest.mark.live_test_only

tools/azure-sdk-tools/devtools_testutils/sanitizers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import TYPE_CHECKING
88

99
from .config import PROXY_URL
10-
from .helpers import get_recording_id, is_live_and_not_recording
10+
from .helpers import get_recording_id, is_live, is_live_and_not_recording
1111

1212
if TYPE_CHECKING:
1313
from typing import Any, Dict, Optional
@@ -235,7 +235,7 @@ def _send_matcher_request(matcher, headers, parameters=None):
235235
:param dict headers: Any matcher headers, as a dictionary.
236236
"""
237237

238-
if is_live_and_not_recording():
238+
if is_live():
239239
return
240240

241241
headers_to_send = {"x-abstraction-identifier": matcher}

0 commit comments

Comments
 (0)