Skip to content

Commit

Permalink
Fixing Azure#12319
Browse files Browse the repository at this point in the history
  • Loading branch information
kinelski committed Aug 22, 2023
1 parent a96ee72 commit 4f031fa
Showing 1 changed file with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,28 +410,18 @@ public async Task StartRecognizeCustomFormsWithoutLabels(bool useStream, bool in
}

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

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

if (useStream)
{
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipage);
using (Recording.DisableRequestBodyRecording())
{
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
}
}
else
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipage);
using (Recording.DisableRequestBodyRecording())
{
var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceMultipage);
operation = await client.StartRecognizeCustomFormsFromUriAsync(trainedModel.ModelId, uri, options);
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
}

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

[RecordedTest]
public async Task StartRecognizeCustomFormsFromUriWithoutLabelsThrowsWithMultipageForm()
{
var client = CreateFormRecognizerClient();
var options = new RecognizeCustomFormsOptions() { IncludeFieldElements = true };

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

var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceMultipage);
var operation = await client.StartRecognizeCustomFormsFromUriAsync(trainedModel.ModelId, uri, options);

var exception = Assert.ThrowsAsync<RequestFailedException>(async () => await operation.WaitForCompletionAsync());

Assert.AreEqual("2002", exception.ErrorCode);
}

[RecordedTest]
public async Task StartRecognizeCustomFormsWithoutLabelsCanParseBlankPage()
{
Expand Down Expand Up @@ -500,28 +506,18 @@ public async Task StartRecognizeCustomFormsWithoutLabelsCanParseBlankPage()
}

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

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

if (useStream)
{
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipageBlank);
using (Recording.DisableRequestBodyRecording())
{
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
}
}
else
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipageBlank);
using (Recording.DisableRequestBodyRecording())
{
var uri = FormRecognizerTestEnvironment.CreateUri(TestFile.InvoiceMultipageBlank);
operation = await client.StartRecognizeCustomFormsFromUriAsync(trainedModel.ModelId, uri, options);
operation = await client.StartRecognizeCustomFormsAsync(trainedModel.ModelId, stream, options);
}

RecognizedFormCollection recognizedForms = await operation.WaitForCompletionAsync();
Expand Down

0 comments on commit 4f031fa

Please sign in to comment.