Skip to content

Commit 76fcba8

Browse files
authored
[DocumentIntelligence] Added missing OperationWithId tests (Azure#47559)
1 parent 61c4a3c commit 76fcba8

File tree

3 files changed

+70
-12
lines changed

3 files changed

+70
-12
lines changed

sdk/documentintelligence/Azure.AI.DocumentIntelligence/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/documentintelligence/Azure.AI.DocumentIntelligence",
5-
"Tag": "net/documentintelligence/Azure.AI.DocumentIntelligence_1586f1c28d"
5+
"Tag": "net/documentintelligence/Azure.AI.DocumentIntelligence_9aad7e91a7"
66
}

sdk/documentintelligence/Azure.AI.DocumentIntelligence/tests/DocumentIntelligenceClient/DocumentBatchLiveTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public DocumentBatchLiveTests(bool isAsync)
1818
{
1919
}
2020

21-
[Test]
21+
[RecordedTest]
2222
public async Task AnalyzeBatchDocuments()
2323
{
2424
var client = CreateDocumentIntelligenceClient();
@@ -38,7 +38,7 @@ public async Task AnalyzeBatchDocuments()
3838
ValidateAcordAnalyzeBatchResult(operation.Value);
3939
}
4040

41-
[Test]
41+
[RecordedTest]
4242
public async Task GetAnalyzeBatchResult()
4343
{
4444
var client = CreateDocumentIntelligenceClient();
@@ -65,7 +65,7 @@ public async Task GetAnalyzeBatchResult()
6565
DocumentAssert.AreEqual(operation.Value, operationDetails.Result);
6666
}
6767

68-
[Test]
68+
[RecordedTest]
6969
public async Task GetAnalyzeBatchResults()
7070
{
7171
var client = CreateDocumentIntelligenceClient();
@@ -121,7 +121,7 @@ public async Task GetAnalyzeBatchResults()
121121
}
122122
}
123123

124-
[Test]
124+
[RecordedTest]
125125
public async Task DeleteAnalyzeBatchResult()
126126
{
127127
var client = CreateDocumentIntelligenceClient();
Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,52 @@ public async Task AnalyzeDocumentOperationCanParseOperationId(WaitUntil waitUnti
3434
var options = new AnalyzeDocumentOptions("prebuilt-receipt", uriSource);
3535

3636
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(waitUntil, options);
37-
await operation.WaitForCompletionAsync();
37+
string operationId = operation.Id;
3838

39-
var match = Regex.Match(operation.Id, AnalysisOperationIdPattern);
39+
var match = Regex.Match(operationId, AnalysisOperationIdPattern);
40+
41+
Assert.That(match.Success);
42+
}
43+
44+
[RecordedTest]
45+
[TestCase(WaitUntil.Started)]
46+
[TestCase(WaitUntil.Completed)]
47+
public async Task AnalyzeBatchDocumentsOperationCanParseOperationId(WaitUntil waitUntil)
48+
{
49+
var client = CreateDocumentIntelligenceClient();
50+
51+
var sourceContainerUri = new Uri(TestEnvironment.BatchSourceBlobSasUrl);
52+
var resultContainerUri = new Uri(TestEnvironment.BatchResultBlobSasUrl);
53+
var blobSource = new BlobContentSource(sourceContainerUri);
54+
var options = new AnalyzeBatchDocumentsOptions("prebuilt-read", blobSource, resultContainerUri)
55+
{
56+
OverwriteExisting = true
57+
};
58+
59+
var operation = await client.AnalyzeBatchDocumentsAsync(waitUntil, options);
60+
string operationId = operation.Id;
61+
62+
var match = Regex.Match(operationId, AnalysisOperationIdPattern);
63+
64+
Assert.That(match.Success);
65+
}
66+
67+
[RecordedTest]
68+
[TestCase(WaitUntil.Started)]
69+
[TestCase(WaitUntil.Completed)]
70+
public async Task ClassifyDocumentOperationCanParseOperationId(WaitUntil waitUntil)
71+
{
72+
var client = CreateDocumentIntelligenceClient();
73+
74+
await using var disposableClassifier = await BuildDisposableDocumentClassifierAsync();
75+
76+
var uriSource = DocumentIntelligenceTestEnvironment.CreateUri(TestFile.Irs1040);
77+
var options = new ClassifyDocumentOptions(disposableClassifier.ClassifierId, uriSource);
78+
79+
var operation = await client.ClassifyDocumentAsync(waitUntil, options);
80+
string operationId = operation.Id;
81+
82+
var match = Regex.Match(operationId, AnalysisOperationIdPattern);
4083

4184
Assert.That(match.Success);
4285
}
@@ -54,10 +97,13 @@ public async Task BuildDocumentModelOperationCanParseOperationId(WaitUntil waitU
5497
var options = new BuildDocumentModelOptions(modelId, DocumentBuildMode.Template, source);
5598

5699
Operation<DocumentModelDetails> operation = null;
100+
string operationId = null;
57101

58102
try
59103
{
60104
operation = await client.BuildDocumentModelAsync(waitUntil, options);
105+
operationId = operation.Id;
106+
61107
await operation.WaitForCompletionAsync();
62108
}
63109
finally
@@ -68,7 +114,7 @@ public async Task BuildDocumentModelOperationCanParseOperationId(WaitUntil waitU
68114
}
69115
}
70116

71-
var match = Regex.Match(operation.Id, TrainingOperationIdPattern);
117+
var match = Regex.Match(operationId, TrainingOperationIdPattern);
72118

73119
Assert.That(match.Success);
74120
}
@@ -88,10 +134,13 @@ public async Task CopyModelToOperationCanParseOperationId(WaitUntil waitUntil)
88134
ModelCopyAuthorization copyAuthorization = await client.AuthorizeModelCopyAsync(authorizeCopyOptions);
89135

90136
Operation<DocumentModelDetails> operation = null;
137+
string operationId = null;
91138

92139
try
93140
{
94141
operation = await client.CopyModelToAsync(waitUntil, disposableModel.ModelId, copyAuthorization);
142+
operationId = operation.Id;
143+
95144
await operation.WaitForCompletionAsync();
96145
}
97146
finally
@@ -102,7 +151,7 @@ public async Task CopyModelToOperationCanParseOperationId(WaitUntil waitUntil)
102151
}
103152
}
104153

105-
var match = Regex.Match(operation.Id, TrainingOperationIdPattern);
154+
var match = Regex.Match(operationId, TrainingOperationIdPattern);
106155

107156
Assert.That(match.Success);
108157
}
@@ -129,10 +178,13 @@ public async Task ComposeModelOperationCanParseOperationId(WaitUntil waitUntil)
129178
var options = new ComposeModelOptions(modelId, disposableClassifier.ClassifierId, docTypes);
130179

131180
Operation<DocumentModelDetails> operation = null;
181+
string operationId = null;
132182

133183
try
134184
{
135185
operation = await client.ComposeModelAsync(waitUntil, options);
186+
operationId = operation.Id;
187+
136188
await operation.WaitForCompletionAsync();
137189
}
138190
finally
@@ -143,7 +195,7 @@ public async Task ComposeModelOperationCanParseOperationId(WaitUntil waitUntil)
143195
}
144196
}
145197

146-
var match = Regex.Match(operation.Id, TrainingOperationIdPattern);
198+
var match = Regex.Match(operationId, TrainingOperationIdPattern);
147199

148200
Assert.That(match.Success);
149201
}
@@ -170,10 +222,13 @@ public async Task BuildClassifierOperationCanParseOperationId(WaitUntil waitUnti
170222
var options = new BuildClassifierOptions(classifierId, docTypes);
171223

172224
Operation<DocumentClassifierDetails> operation = null;
225+
string operationId = null;
173226

174227
try
175228
{
176229
operation = await client.BuildClassifierAsync(waitUntil, options);
230+
operationId = operation.Id;
231+
177232
await operation.WaitForCompletionAsync();
178233
}
179234
finally
@@ -184,7 +239,7 @@ public async Task BuildClassifierOperationCanParseOperationId(WaitUntil waitUnti
184239
}
185240
}
186241

187-
var match = Regex.Match(operation.Id, TrainingOperationIdPattern);
242+
var match = Regex.Match(operationId, TrainingOperationIdPattern);
188243

189244
Assert.That(match.Success);
190245
}
@@ -204,10 +259,13 @@ public async Task CopyClassifierToOperationCanParseOperationId(WaitUntil waitUnt
204259
ClassifierCopyAuthorization copyAuthorization = await client.AuthorizeClassifierCopyAsync(authorizeCopyOptions);
205260

206261
Operation<DocumentClassifierDetails> operation = null;
262+
string operationId = null;
207263

208264
try
209265
{
210266
operation = await client.CopyClassifierToAsync(waitUntil, disposableClassifier.ClassifierId, copyAuthorization);
267+
operationId = operation.Id;
268+
211269
await operation.WaitForCompletionAsync();
212270
}
213271
finally
@@ -218,7 +276,7 @@ public async Task CopyClassifierToOperationCanParseOperationId(WaitUntil waitUnt
218276
}
219277
}
220278

221-
var match = Regex.Match(operation.Id, TrainingOperationIdPattern);
279+
var match = Regex.Match(operationId, TrainingOperationIdPattern);
222280

223281
Assert.That(match.Success);
224282
}

0 commit comments

Comments
 (0)