Skip to content

Commit 15eaba8

Browse files
authored
[FormRecognizer] Fixing a couple of minor issues (Azure#38339)
1 parent c50ce60 commit 15eaba8

File tree

15 files changed

+325
-185
lines changed

15 files changed

+325
-185
lines changed

sdk/formrecognizer/Azure.AI.FormRecognizer/api/Azure.AI.FormRecognizer.netstandard2.0.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace Azure.AI.FormRecognizer
22
{
33
public enum FormContentType
44
{
5+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
56
Json = 0,
67
Pdf = 1,
78
Png = 2,

sdk/formrecognizer/Azure.AI.FormRecognizer/samples/Sample_ModelCompose.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ var client = new DocumentModelAdministrationClient(new Uri(endpoint), credential
2424
In our case, we will be writing an application that collects the expenses a company is making. There are 4 main areas where we get purchase orders from (office supplies, office equipment, furniture, and cleaning supplies). Because each area has its own document with its own structure, we need to create a model per document type.
2525

2626
```C# Snippet:FormRecognizerSampleBuildVariousModels
27-
// For this sample, you can use the training forms found in the `trainingFiles` folder.
28-
// Upload the forms to your storage container and then generate a container SAS URL.
29-
// For instructions on setting up forms for training in an Azure Storage Blob Container, see
27+
// For this sample, you can use the training documents found in the `trainingFiles` folder.
28+
// Upload the documents to your storage container and then generate a container SAS URL.
29+
// For instructions on setting up documents for training in an Azure Storage Blob Container, see
3030
// https://aka.ms/azsdk/formrecognizer/buildtrainingset
3131
3232
Uri officeSuppliesUri = new Uri("<purchaseOrderOfficeSuppliesUri>");

sdk/formrecognizer/Azure.AI.FormRecognizer/src/FormRecognizerClient/FormContentType.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System.ComponentModel;
5+
46
namespace Azure.AI.FormRecognizer
57
{
68
/// <summary>
@@ -11,6 +13,7 @@ public enum FormContentType
1113
/// <summary>
1214
/// Used for JSON files.
1315
/// </summary>
16+
[EditorBrowsable(EditorBrowsableState.Never)]
1417
Json,
1518

1619
/// <summary>

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/DocumentAnalysisClient/DocumentAnalysisClientLiveTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public async Task AnalyzeDocumentWithCustomModel(bool useStream)
270270
}
271271

272272
[RecordedTest]
273-
public async Task AnalyzeDocumentWithCustomModelWithLabelsAndSelectionMarks()
273+
public async Task AnalyzeDocumentWithCustomModelWithSelectionMarks()
274274
{
275275
var client = CreateDocumentAnalysisClient();
276276
var modelId = Recording.GenerateId();
@@ -308,7 +308,7 @@ public async Task AnalyzeDocumentWithCustomModelWithLabelsAndSelectionMarks()
308308
[RecordedTest]
309309
[TestCase(true)]
310310
[TestCase(false)]
311-
public async Task AnalyzeDocumentWithCustomModelCanParseMultipageForm(bool useStream)
311+
public async Task AnalyzeDocumentWithCustomModelCanParseMultipageDocument(bool useStream)
312312
{
313313
var client = CreateDocumentAnalysisClient();
314314
var modelId = Recording.GenerateId();
@@ -364,7 +364,7 @@ public async Task AnalyzeDocumentWithCustomModelCanParseMultipageForm(bool useSt
364364
[RecordedTest]
365365
[TestCase(true)]
366366
[TestCase(false)]
367-
public async Task AnalyzeDocumentWithCustomModelCanParseMultipageFormWithBlankPage(bool useStream)
367+
public async Task AnalyzeDocumentWithCustomModelCanParseMultipageDocumentWithBlankPage(bool useStream)
368368
{
369369
var client = CreateDocumentAnalysisClient();
370370
var modelId = Recording.GenerateId();
@@ -413,7 +413,7 @@ public async Task AnalyzeDocumentWithCustomModelCanParseMultipageFormWithBlankPa
413413
}
414414

415415
[RecordedTest]
416-
public async Task AnalyzeDocumentWithCustomModelCanParseDifferentTypeOfForm()
416+
public async Task AnalyzeDocumentWithCustomModelCanParseDifferentTypeOfDocument()
417417
{
418418
var client = CreateDocumentAnalysisClient();
419419
var modelId = Recording.GenerateId();
@@ -545,7 +545,7 @@ public async Task AnalyzeDocumentPopulatesDocumentPageJpg(bool useStream)
545545
DocumentPage page = result.Pages.Single();
546546

547547
// The expected values are based on the values returned by the service, and not the actual
548-
// values present in the form. We are not testing the service here, but the SDK.
548+
// values present in the document. We are not testing the service here, but the SDK.
549549

550550
Assert.AreEqual(DocumentPageLengthUnit.Pixel, page.Unit);
551551
Assert.AreEqual(1700, page.Width);
@@ -1028,7 +1028,7 @@ public async Task AnalyzeDocumentPopulatesLayoutPagePdf(bool useStream)
10281028
DocumentPage page = result.Pages.Single();
10291029

10301030
// The expected values are based on the values returned by the service, and not the actual
1031-
// values present in the form. We are not testing the service here, but the SDK.
1031+
// values present in the document. We are not testing the service here, but the SDK.
10321032

10331033
Assert.AreEqual(DocumentPageLengthUnit.Inch, page.Unit);
10341034
Assert.AreEqual(8.5, page.Width);
@@ -1235,7 +1235,7 @@ public async Task AnalyzeDocumentCanReadPageAndLanguage(bool useStream)
12351235
DocumentPage page = result.Pages.Single();
12361236

12371237
// The expected values are based on the values returned by the service, and not the actual
1238-
// values present in the form. We are not testing the service here, but the SDK.
1238+
// values present in the document. We are not testing the service here, but the SDK.
12391239

12401240
Assert.AreEqual(DocumentPageLengthUnit.Inch, page.Unit);
12411241
Assert.AreEqual(8.5, page.Width);

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/DocumentModelAdministrationClient/DocumentClassifierAdministrationLiveTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public async Task BuildDocumentClassifierWithAzureBlobFileListSource()
160160
#region Get
161161

162162
[RecordedTest]
163-
[TestCase(true, Ignore = "https://github.com/Azure/azure-sdk-for-net/issues/35243")]
163+
[TestCase(true)]
164164
[TestCase(false)]
165165
public async Task GetDocumentClassifier(bool useTokenCredential)
166166
{

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormRecognizerClient/RecognizeBusinessCardsLiveTests.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@
88
using Azure.Core.TestFramework;
99
using NUnit.Framework;
1010

11-
/// <summary>
12-
/// The suite of tests for the `StartRecognizeBusinessCards` methods in the <see cref="FormRecognizerClient"/> class.
13-
/// </summary>
14-
/// <remarks>
15-
/// These tests have a dependency on live Azure services and may incur costs for the associated
16-
/// Azure subscription.
17-
/// </remarks>
1811
namespace Azure.AI.FormRecognizer.Tests
1912
{
13+
/// <summary>
14+
/// The suite of tests for the `StartRecognizeBusinessCards` methods in the <see cref="FormRecognizerClient"/> class.
15+
/// </summary>
16+
/// <remarks>
17+
/// These tests have a dependency on live Azure services and may incur costs for the associated
18+
/// Azure subscription.
19+
/// </remarks>
2020
[ClientTestFixture(FormRecognizerClientOptions.ServiceVersion.V2_1)]
21-
2221
public class RecognizeBusinessCardsLiveTests : FormRecognizerLiveTestBase
2322
{
2423
public RecognizeBusinessCardsLiveTests(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormRecognizerClient/RecognizeContentLiveTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
using Azure.Core.TestFramework;
99
using NUnit.Framework;
1010

11-
/// <summary>
12-
/// The suite of tests for the `StartRecognizeContent` methods in the <see cref="FormRecognizerClient"/> class.
13-
/// </summary>
14-
/// <remarks>
15-
/// These tests have a dependency on live Azure services and may incur costs for the associated
16-
/// Azure subscription.
17-
/// </remarks>
1811
namespace Azure.AI.FormRecognizer.Tests
1912
{
13+
/// <summary>
14+
/// The suite of tests for the `StartRecognizeContent` methods in the <see cref="FormRecognizerClient"/> class.
15+
/// </summary>
16+
/// <remarks>
17+
/// These tests have a dependency on live Azure services and may incur costs for the associated
18+
/// Azure subscription.
19+
/// </remarks>
2020
[ClientTestFixture(
2121
FormRecognizerClientOptions.ServiceVersion.V2_0,
2222
FormRecognizerClientOptions.ServiceVersion.V2_1)]

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormRecognizerClient/RecognizeCustomFormsLiveTests.cs

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
using Azure.Core.TestFramework;
99
using NUnit.Framework;
1010

11-
/// <summary>
12-
/// The suite of tests for the `StartRecognizeCustomForms` methods in the <see cref="FormRecognizerClient"/> class.
13-
/// </summary>
14-
/// <remarks>
15-
/// These tests have a dependency on live Azure services and may incur costs for the associated
16-
/// Azure subscription.
17-
/// </remarks>
1811
namespace Azure.AI.FormRecognizer.Tests
1912
{
13+
/// <summary>
14+
/// The suite of tests for the `StartRecognizeCustomForms` methods in the <see cref="FormRecognizerClient"/> class.
15+
/// </summary>
16+
/// <remarks>
17+
/// These tests have a dependency on live Azure services and may incur costs for the associated
18+
/// Azure subscription.
19+
/// </remarks>
2020
[ClientTestFixture(
2121
FormRecognizerClientOptions.ServiceVersion.V2_0,
2222
FormRecognizerClientOptions.ServiceVersion.V2_1)]
@@ -410,28 +410,18 @@ public async Task StartRecognizeCustomFormsWithoutLabels(bool useStream, bool in
410410
}
411411

412412
[RecordedTest]
413-
[TestCase(true)]
414-
[TestCase(false, Ignore = "https://github.com/Azure/azure-sdk-for-net/issues/12319")]
415-
public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageForm(bool useStream)
413+
public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageForm()
416414
{
417415
var client = CreateFormRecognizerClient();
418416
var options = new RecognizeCustomFormsOptions() { IncludeFieldElements = true };
419417
RecognizeCustomFormsOperation operation;
420418

421419
await using var trainedModel = await CreateDisposableTrainedModelAsync(useTrainingLabels: false, ContainerType.MultipageFiles);
422420

423-
if (useStream)
424-
{
425-
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipage);
426-
using (Recording.DisableRequestBodyRecording())
427-
{
428-
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
429-
}
430-
}
431-
else
421+
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipage);
422+
using (Recording.DisableRequestBodyRecording())
432423
{
433-
var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceMultipage);
434-
operation = await client.StartRecognizeCustomFormsFromUriAsync(trainedModel.ModelId, uri, options);
424+
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
435425
}
436426

437427
RecognizedFormCollection recognizedForms = await operation.WaitForCompletionAsync();
@@ -465,6 +455,22 @@ public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageForm(bo
465455
Assert.AreEqual("Southridge Video", secondFormFieldInPage.ValueData.Text);
466456
}
467457

458+
[RecordedTest]
459+
public async Task StartRecognizeCustomFormsFromUriWithoutLabelsThrowsWithMultipageForm()
460+
{
461+
var client = CreateFormRecognizerClient();
462+
var options = new RecognizeCustomFormsOptions() { IncludeFieldElements = true };
463+
464+
await using var trainedModel = await CreateDisposableTrainedModelAsync(useTrainingLabels: false, ContainerType.MultipageFiles);
465+
466+
var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceMultipage);
467+
var operation = await client.StartRecognizeCustomFormsFromUriAsync(trainedModel.ModelId, uri, options);
468+
469+
var exception = Assert.ThrowsAsync<RequestFailedException>(async () => await operation.WaitForCompletionAsync());
470+
471+
Assert.AreEqual("2002", exception.ErrorCode);
472+
}
473+
468474
[RecordedTest]
469475
public async Task StartRecognizeCustomFormsWithoutLabelsCanParseBlankPage()
470476
{
@@ -500,28 +506,18 @@ public async Task StartRecognizeCustomFormsWithoutLabelsCanParseBlankPage()
500506
}
501507

502508
[RecordedTest]
503-
[TestCase(true)]
504-
[TestCase(false, Ignore = "https://github.com/Azure/azure-sdk-for-net/issues/12319")]
505-
public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageFormWithBlankPage(bool useStream)
509+
public async Task StartRecognizeCustomFormsWithoutLabelsCanParseMultipageFormWithBlankPage()
506510
{
507511
var client = CreateFormRecognizerClient();
508512
var options = new RecognizeCustomFormsOptions() { IncludeFieldElements = true };
509513
RecognizeCustomFormsOperation operation;
510514

511515
await using var trainedModel = await CreateDisposableTrainedModelAsync(useTrainingLabels: false);
512516

513-
if (useStream)
514-
{
515-
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipageBlank);
516-
using (Recording.DisableRequestBodyRecording())
517-
{
518-
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
519-
}
520-
}
521-
else
517+
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipageBlank);
518+
using (Recording.DisableRequestBodyRecording())
522519
{
523-
var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceMultipageBlank);
524-
operation = await client.StartRecognizeCustomFormsFromUriAsync(trainedModel.ModelId, uri, options);
520+
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
525521
}
526522

527523
RecognizedFormCollection recognizedForms = await operation.WaitForCompletionAsync();

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormRecognizerClient/RecognizeIdentityDocumentsLiveTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
using Azure.Core.TestFramework;
99
using NUnit.Framework;
1010

11-
/// <summary>
12-
/// The suite of tests for the `StartRecognizeIdentityDocuments` methods in the <see cref="FormRecognizerClient"/> class.
13-
/// </summary>
14-
/// <remarks>
15-
/// These tests have a dependency on live Azure services and may incur costs for the associated
16-
/// Azure subscription.
17-
/// </remarks>
1811
namespace Azure.AI.FormRecognizer.Tests
1912
{
13+
/// <summary>
14+
/// The suite of tests for the `StartRecognizeIdentityDocuments` methods in the <see cref="FormRecognizerClient"/> class.
15+
/// </summary>
16+
/// <remarks>
17+
/// These tests have a dependency on live Azure services and may incur costs for the associated
18+
/// Azure subscription.
19+
/// </remarks>
2020
[ClientTestFixture(FormRecognizerClientOptions.ServiceVersion.V2_1)]
2121
public class RecognizeIdentityDocumentsLiveTests : FormRecognizerLiveTestBase
2222
{

sdk/formrecognizer/Azure.AI.FormRecognizer/tests/FormRecognizerClient/RecognizeInvoicesLiveTests.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@
99
using Azure.Core.TestFramework;
1010
using NUnit.Framework;
1111

12-
/// <summary>
13-
/// The suite of tests for the `StartRecognizeInvoices` methods in the <see cref="FormRecognizerClient"/> class.
14-
/// </summary>
15-
/// <remarks>
16-
/// These tests have a dependency on live Azure services and may incur costs for the associated
17-
/// Azure subscription.
18-
/// </remarks>
1912
namespace Azure.AI.FormRecognizer.Tests
2013
{
14+
/// <summary>
15+
/// The suite of tests for the `StartRecognizeInvoices` methods in the <see cref="FormRecognizerClient"/> class.
16+
/// </summary>
17+
/// <remarks>
18+
/// These tests have a dependency on live Azure services and may incur costs for the associated
19+
/// Azure subscription.
20+
/// </remarks>
2121
[ClientTestFixture(FormRecognizerClientOptions.ServiceVersion.V2_1)]
22-
2322
public class RecognizeInvoicesLiveTests : FormRecognizerLiveTestBase
2423
{
2524
public RecognizeInvoicesLiveTests(bool isAsync, FormRecognizerClientOptions.ServiceVersion serviceVersion)

0 commit comments

Comments
 (0)