Skip to content

Commit

Permalink
[formrecognizer] Enable copy model tests (Azure#24917)
Browse files Browse the repository at this point in the history
* enable sync copy model tests

* enable async copy tests

* add bodiless matcher

* sanitize targetResourceId
  • Loading branch information
catalinaperalta authored Jun 23, 2022
1 parent 46f5819 commit 92291c9
Show file tree
Hide file tree
Showing 15 changed files with 4,467 additions and 49 deletions.
6 changes: 5 additions & 1 deletion sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ def add_sanitizers(test_proxy):
value="redacted",
regex="([0-9a-f-]{36})",
)

add_body_key_sanitizer(
json_path="targetResourceId",
value="/path/to/resource/id",
regex="^.*",
)
add_body_key_sanitizer(
json_path="copyAuthorization.accessToken",
value="redacted",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"Entries": [
{
"RequestUri": "https://fakeendpoint.cognitiveservices.azure.com/formrecognizer/documentModels:build?api-version=2022-06-30-preview",
"RequestMethod": "POST",
"RequestHeaders": {
"Accept": "application/json",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Content-Length": "131",
"Content-Type": "application/json",
"User-Agent": "azsdk-python-ai-formrecognizer/3.2.0b6 Python/3.8.5 (Windows-10-10.0.19041-SP0)"
},
"RequestBody": {
"modelId": "65f7c719-6f76-46af-864b-ea107a13f249",
"buildMode": "template",
"azureBlobSource": {
"containerUrl": "https://blob_sas_url"
}
},
"StatusCode": 202,
"ResponseHeaders": {
"apim-request-id": "710abb63-2fa8-49f6-b79f-f730d1e11fc4",
"Content-Length": "0",
"Date": "Thu, 23 Jun 2022 00:55:33 GMT",
"operation-location": "https://fakeendpoint.cognitiveservices.azure.com/formrecognizer/operations/31510422268_710abb63-2fa8-49f6-b79f-f730d1e11fc4?api-version=2022-06-30-preview",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload",
"X-Content-Type-Options": "nosniff",
"x-envoy-upstream-service-time": "923"
},
"ResponseBody": null
},
{
"RequestUri": "https://fakeendpoint.cognitiveservices.azure.com/formrecognizer/operations/31510422268_710abb63-2fa8-49f6-b79f-f730d1e11fc4?api-version=2022-06-30-preview",
"RequestMethod": "GET",
"RequestHeaders": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"User-Agent": "azsdk-python-ai-formrecognizer/3.2.0b6 Python/3.8.5 (Windows-10-10.0.19041-SP0)"
},
"RequestBody": null,
"StatusCode": 200,
"ResponseHeaders": {
"apim-request-id": "5b4113d4-58f2-40d8-97ba-0f0479a383cc",
"Content-Type": "application/json; charset=utf-8",
"Date": "Thu, 23 Jun 2022 00:55:37 GMT",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload",
"Transfer-Encoding": "chunked",
"X-Content-Type-Options": "nosniff",
"x-envoy-upstream-service-time": "16"
},
"ResponseBody": {
"operationId": "31510422268_710abb63-2fa8-49f6-b79f-f730d1e11fc4",
"kind": "documentModelBuild",
"status": "succeeded",
"createdDateTime": "2022-06-23T00:55:32Z",
"lastUpdatedDateTime": "2022-06-23T00:55:35Z",
"resourceLocation": "https://fakeendpoint.cognitiveservices.azure.com/formrecognizer/documentModels/65f7c719-6f76-46af-864b-ea107a13f249?api-version=2022-06-30-preview",
"percentCompleted": 100,
"result": {
"docTypes": {
"65f7c719-6f76-46af-864b-ea107a13f249": {
"fieldSchema": {
"Merchant": {
"type": "string"
},
"PhoneNumber": {
"type": "string"
},
"Website": {
"type": "string"
},
"Email": {
"type": "string"
},
"PurchaseOrderNumber": {
"type": "string"
},
"DatedAs": {
"type": "string"
},
"VendorName": {
"type": "string"
},
"CompanyName": {
"type": "string"
},
"CompanyAddress": {
"type": "string"
},
"CompanyPhoneNumber": {
"type": "string"
},
"Subtotal": {
"type": "string"
},
"Tax": {
"type": "string"
},
"Total": {
"type": "string"
},
"Signature": {
"type": "string"
},
"Quantity": {
"type": "number"
},
"FullSignature": {
"type": "signature"
}
},
"buildMode": "template",
"fieldConfidence": {
"CompanyAddress": 0.8,
"CompanyName": 0.995,
"CompanyPhoneNumber": 0.995,
"DatedAs": 0.995,
"Email": 0.8,
"FullSignature": 0.6,
"Merchant": 0.995,
"PhoneNumber": 0.995,
"PurchaseOrderNumber": 0.995,
"Quantity": 0.995,
"Signature": 0.995,
"Subtotal": 0.995,
"Tax": 0.995,
"Total": 0.995,
"VendorName": 0.995,
"Website": 0.995
}
}
},
"modelId": "65f7c719-6f76-46af-864b-ea107a13f249",
"createdDateTime": "2022-06-23T00:55:35Z",
"apiVersion": "2022-06-30-preview"
}
}
},
{
"RequestUri": "https://fakeendpoint.cognitiveservices.azure.com/formrecognizer/documentModels:authorizeCopy?api-version=2022-06-30-preview",
"RequestMethod": "POST",
"RequestHeaders": {
"Accept": "application/json",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Content-Length": "51",
"Content-Type": "application/json",
"User-Agent": "azsdk-python-ai-formrecognizer/3.2.0b6 Python/3.8.5 (Windows-10-10.0.19041-SP0)"
},
"RequestBody": {
"modelId": "7a0e94fb-12f3-43ee-a933-21d5c1899a3f"
},
"StatusCode": 200,
"ResponseHeaders": {
"apim-request-id": "3520d491-6b71-464c-8c98-9b929ccfedbd",
"Content-Type": "application/json; charset=utf-8",
"Date": "Thu, 23 Jun 2022 00:55:37 GMT",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload",
"Transfer-Encoding": "chunked",
"X-Content-Type-Options": "nosniff",
"x-envoy-upstream-service-time": "106"
},
"ResponseBody": {
"targetResourceId": "/path/to/resource/id",
"targetResourceRegion": "westus2",
"targetModelId": "7a0e94fb-12f3-43ee-a933-21d5c1899a3f",
"targetModelLocation": "https://fakeendpoint.cognitiveservices.azure.com/formrecognizer/documentModels/7a0e94fb-12f3-43ee-a933-21d5c1899a3f?api-version=2022-06-30-preview",
"accessToken": "redacted",
"expirationDateTime": "2022-06-23T01:55:38Z"
}
},
{
"RequestUri": "https://fakeendpoint.cognitiveservices.azure.com/formrecognizer/documentModels/00000000-0000-0000-0000-000000000000:copyTo?api-version=2022-06-30-preview",
"RequestMethod": "POST",
"RequestHeaders": {
"Accept": "application/json",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Content-Length": "375",
"Content-Type": "application/json",
"User-Agent": "azsdk-python-ai-formrecognizer/3.2.0b6 Python/3.8.5 (Windows-10-10.0.19041-SP0)"
},
"RequestBody": {
"targetResourceId": "/path/to/resource/id",
"targetResourceRegion": "westus2",
"targetModelId": "7a0e94fb-12f3-43ee-a933-21d5c1899a3f",
"targetModelLocation": "https://fakeendpoint.cognitiveservices.azure.com/formrecognizer/documentModels/7a0e94fb-12f3-43ee-a933-21d5c1899a3f?api-version=2022-06-30-preview",
"accessToken": "redacted",
"expirationDateTime": "2022-06-23T01:55:38.000Z"
},
"StatusCode": 404,
"ResponseHeaders": {
"apim-request-id": "a2ca5b95-59a1-437b-a2ba-939b40f3d9cc",
"Content-Type": "application/json",
"Date": "Thu, 23 Jun 2022 00:55:38 GMT",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload",
"Transfer-Encoding": "chunked",
"X-Content-Type-Options": "nosniff",
"x-envoy-upstream-service-time": "37"
},
"ResponseBody": {
"error": {
"code": "NotFound",
"message": "Resource not found.",
"innererror": {
"code": "ModelNotFound",
"message": "The requested model was not found."
}
}
}
}
],
"Variables": {}
}
Loading

0 comments on commit 92291c9

Please sign in to comment.