Skip to content

Commit 4667c14

Browse files
authored
♻️ update test data structure (#425)
1 parent d72cd6e commit 4667c14

7 files changed

Lines changed: 39 additions & 40 deletions

File tree

src/v2/parsing/inference/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// Inference
1+
export { BaseInference } from "./baseInference.js";
22
export { InferenceFile } from "./inferenceFile.js";
33
export { InferenceModel } from "./inferenceModel.js";
4-
export { BaseInference } from "./baseInference.js";
5-
6-
// Fields
74
export * as field from "./field/index.js";

tests/v2/client.integration.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import { SimpleField } from "@/v2/parsing/inference/field/index.js";
1616
import { MindeeHttpErrorV2 } from "@/v2/http/index.js";
1717
import * as fs from "node:fs";
18-
import { RESOURCE_PATH, V2_PRODUCT_PATH, V2_RESOURCE_PATH } from "../index.js";
18+
import { RESOURCE_PATH, V2_PRODUCT_PATH } from "../index.js";
1919
import { Extraction } from "@/v2/product/index.js";
2020

2121
function check422(err: unknown) {
@@ -49,6 +49,7 @@ describe("MindeeV2 – Client Integration Tests", () => {
4949
);
5050
const sampleImagePath = path.join(
5151
V2_PRODUCT_PATH,
52+
"extraction",
5253
"financial_document",
5354
"default_sample.jpg",
5455
);
@@ -58,7 +59,7 @@ describe("MindeeV2 – Client Integration Tests", () => {
5859
"receipt.txt",
5960
);
6061
const dataSchemaReplacePath = path.join(
61-
V2_RESOURCE_PATH, "inference/data_schema_replace_param.json"
62+
V2_PRODUCT_PATH, "extraction/data_schema_replace_param.json"
6263
);
6364
let dataSchemaReplace: string;
6465

@@ -72,7 +73,7 @@ describe("MindeeV2 – Client Integration Tests", () => {
7273
dataSchemaReplace = fs.readFileSync(dataSchemaReplacePath).toString();
7374
});
7475

75-
it("Empty, multi-page PDF – PathInput - enqueueAndGetInference must succeed", async () => {
76+
it("Empty, multi-page PDF – PathInput - enqueueAndGetResult must succeed", async () => {
7677
const source = new PathInput({ inputPath: emptyPdfPath });
7778
const params = {
7879
modelId,
@@ -99,7 +100,7 @@ describe("MindeeV2 – Client Integration Tests", () => {
99100
checkEmptyActiveOptions(inference);
100101
}).timeout(60000);
101102

102-
it("Filled, single-page image – PathInput - enqueueAndGetInference must succeed", async () => {
103+
it("Filled, single-page image – PathInput - enqueueAndGetResult must succeed", async () => {
103104
const source = new PathInput({ inputPath: sampleImagePath });
104105
const params = {
105106
modelId,
@@ -138,7 +139,7 @@ describe("MindeeV2 – Client Integration Tests", () => {
138139
expect(inference.result.rawText?.pages).to.have.lengthOf(1);
139140
}).timeout(120000);
140141

141-
it("Filled, single-page image – Base64Input - enqueueAndGetInference must succeed", async () => {
142+
it("Filled, single-page image – Base64Input - enqueueAndGetResult must succeed", async () => {
142143
const data = fs.readFileSync(sampleBase64Path, "utf8");
143144
const source = new Base64Input({ inputString: data, filename: "receipt.jpg" });
144145
const params = {
@@ -193,7 +194,7 @@ describe("MindeeV2 – Client Integration Tests", () => {
193194
}
194195
}).timeout(60000);
195196

196-
it("HTTPS URL – enqueue & get inference must succeed", async () => {
197+
it("HTTPS URL – enqueueAndGetResult must succeed", async () => {
197198
const url = process.env.MINDEE_V2_SE_TESTS_BLANK_PDF_URL ?? "error-no-url-found";
198199
const source = new UrlInput({ url });
199200
const params = new ExtractionParameters({

tests/v2/client.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ describe("MindeeV2 - ClientV2", () => {
119119
inputPath: path.join(
120120
V2_RESOURCE_PATH,
121121
"products",
122+
"extraction",
122123
"financial_document",
123124
"default_sample.jpg"
124125
),

tests/v2/client/inferenceParameter.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { StringDict } from "@/parsing/index.js";
22
import path from "path";
3-
import { V2_RESOURCE_PATH } from "../../index.js";
3+
import { V2_PRODUCT_PATH } from "../../index.js";
44
import { expect } from "chai";
55
import { promises as fs } from "fs";
66
import { ExtractionParameters, DataSchema } from "@/v2/product/extraction/index.js";
@@ -30,7 +30,7 @@ describe("MindeeV2 - Inference Parameter", () => {
3030
describe("Data Schema", () => {
3131
before(async () => {
3232
const fileContents = await fs.readFile(
33-
path.join(V2_RESOURCE_PATH, "inference/data_schema_replace_param.json")
33+
path.join(V2_PRODUCT_PATH, "extraction/data_schema_replace_param.json")
3434
);
3535
expectedDataSchemaDict = JSON.parse(fileContents.toString());
3636
expectedDataSchemaString = JSON.stringify(expectedDataSchemaDict);
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ import {
1313
RagMetadata,
1414
RawText,
1515
} from "@/v2/parsing/index.js";
16-
import { V2_RESOURCE_PATH } from "../../index.js";
16+
import { V2_PRODUCT_PATH } from "../../index.js";
1717
import { ExtractionResponse } from "@/v2/product/index.js";
1818

19-
const findocPath = path.join(V2_RESOURCE_PATH, "products", "financial_document");
20-
const inferencePath = path.join(V2_RESOURCE_PATH, "inference");
21-
const deepNestedFieldPath = path.join(inferencePath, "deep_nested_fields.json");
22-
const standardFieldPath = path.join(inferencePath, "standard_field_types.json");
23-
const standardFieldRstPath = path.join(inferencePath, "standard_field_types.rst");
19+
const findocPath = path.join(V2_PRODUCT_PATH, "extraction", "financial_document");
20+
const extractionPath = path.join(V2_PRODUCT_PATH, "extraction");
21+
const deepNestedFieldPath = path.join(extractionPath, "deep_nested_fields.json");
22+
const standardFieldPath = path.join(extractionPath, "standard_field_types.json");
23+
const standardFieldRstPath = path.join(extractionPath, "standard_field_types.rst");
2424
const locationFieldPath = path.join(findocPath, "complete_with_coordinates.json");
2525

26-
async function loadV2Inference(resourcePath: string): Promise<ExtractionResponse> {
26+
async function loadV2Extraction(resourcePath: string): Promise<ExtractionResponse> {
2727
const localResponse = new LocalResponse(resourcePath);
2828
await localResponse.init();
2929
return localResponse.deserializeResponse(ExtractionResponse);
3030
}
3131

32-
describe("MindeeV2 - Inference Response", async () => {
32+
describe("MindeeV2 - Extraction Response", async () => {
3333
describe("Financial Document", async () => {
3434
it("should load a blank inference with valid properties", async () => {
35-
const response = await loadV2Inference(
35+
const response = await loadV2Extraction(
3636
path.join(findocPath, "blank.json")
3737
);
3838
const fields = response.inference.result.fields;
@@ -64,7 +64,7 @@ describe("MindeeV2 - Inference Response", async () => {
6464
});
6565

6666
it("should load a complete inference with valid properties", async () => {
67-
const response = await loadV2Inference(
67+
const response = await loadV2Extraction(
6868
path.join(findocPath, "complete.json")
6969
);
7070
const inference = response.inference;
@@ -129,7 +129,7 @@ describe("MindeeV2 - Inference Response", async () => {
129129

130130
describe("Deeply Nested", async () => {
131131
it("should load a deep nested object", async () => {
132-
const response = await loadV2Inference(deepNestedFieldPath);
132+
const response = await loadV2Extraction(deepNestedFieldPath);
133133
const fields = response.inference.result.fields;
134134
expect(fields.get("field_simple")).to.be.an.instanceof(SimpleField);
135135
expect(fields.get("field_object")).to.be.an.instanceof(ObjectField);
@@ -165,7 +165,7 @@ describe("MindeeV2 - Inference Response", async () => {
165165

166166
describe("Standard Field Types", async () => {
167167
it("should recognize simple fields", async () => {
168-
const response = await loadV2Inference(standardFieldPath);
168+
const response = await loadV2Extraction(standardFieldPath);
169169
const fields = response.inference.result.fields;
170170

171171
expect(fields.get("field_simple_string")).to.be.instanceOf(SimpleField);
@@ -211,7 +211,7 @@ describe("MindeeV2 - Inference Response", async () => {
211211
});
212212

213213
it("should recognize simple list fields", async () => {
214-
const response = await loadV2Inference(standardFieldPath);
214+
const response = await loadV2Extraction(standardFieldPath);
215215
const fields = response.inference.result.fields;
216216

217217
expect(fields.get("field_simple_list")).to.be.instanceOf(ListField);
@@ -226,7 +226,7 @@ describe("MindeeV2 - Inference Response", async () => {
226226
});
227227

228228
it("should recognize object fields", async () => {
229-
const response = await loadV2Inference(standardFieldPath);
229+
const response = await loadV2Extraction(standardFieldPath);
230230
const fields = response.inference.result.fields;
231231

232232
expect(fields.get("field_object")).to.be.instanceOf(ObjectField);
@@ -246,7 +246,7 @@ describe("MindeeV2 - Inference Response", async () => {
246246
});
247247

248248
it("should recognize object list fields", async () => {
249-
const response = await loadV2Inference(standardFieldPath);
249+
const response = await loadV2Extraction(standardFieldPath);
250250
const fields = response.inference.result.fields;
251251

252252
expect(fields.get("field_object_list")).to.be.instanceOf(ListField);
@@ -272,8 +272,8 @@ describe("MindeeV2 - Inference Response", async () => {
272272

273273
describe("Raw Text", async () => {
274274
it("raw text should be exposed", async () => {
275-
const response = await loadV2Inference(
276-
path.join(inferencePath, "raw_texts.json")
275+
const response = await loadV2Extraction(
276+
path.join(extractionPath, "raw_texts.json")
277277
);
278278
expect(response.inference.result.rag).to.be.undefined;
279279

@@ -291,17 +291,17 @@ describe("MindeeV2 - Inference Response", async () => {
291291

292292
describe("RAG Metadata", async () => {
293293
it("RAG metadata when matched", async () => {
294-
const response = await loadV2Inference(
295-
path.join(inferencePath, "rag_matched.json")
294+
const response = await loadV2Extraction(
295+
path.join(extractionPath, "rag_matched.json")
296296
);
297297
const rag = response.inference.result.rag;
298298
expect(rag).to.be.instanceOf(RagMetadata);
299299
expect(rag?.retrievedDocumentId).to.eq("12345abc-1234-1234-1234-123456789abc");
300300
});
301301

302302
it("RAG metadata when not matched", async () => {
303-
const response = await loadV2Inference(
304-
path.join(inferencePath, "rag_not_matched.json")
303+
const response = await loadV2Extraction(
304+
path.join(extractionPath, "rag_not_matched.json")
305305
);
306306
const rag = response.inference.result.rag;
307307
expect(rag).to.be.instanceOf(RagMetadata);
@@ -311,7 +311,7 @@ describe("MindeeV2 - Inference Response", async () => {
311311

312312
describe("RST Display", async () => {
313313
it("to be properly exposed", async () => {
314-
const response = await loadV2Inference(standardFieldPath);
314+
const response = await loadV2Extraction(standardFieldPath);
315315
const rstString = await fs.readFile(standardFieldRstPath, "utf8");
316316

317317
expect(response.inference).to.not.be.null;
@@ -321,7 +321,7 @@ describe("MindeeV2 - Inference Response", async () => {
321321

322322
describe("Field Locations and Confidence", async () => {
323323
it("to be properly exposed", async () => {
324-
const response = await loadV2Inference(locationFieldPath);
324+
const response = await loadV2Extraction(locationFieldPath);
325325

326326
expect(response.inference).to.not.be.null;
327327

tests/v2/parsing/localResponse.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { expect } from "chai";
33
import { LocalResponse } from "@/v2/index.js";
44

55
import path from "path";
6-
import { V2_RESOURCE_PATH } from "../../index.js";
6+
import { V2_PRODUCT_PATH } from "../../index.js";
77
import { Buffer } from "node:buffer";
88
import { ExtractionResponse } from "@/v2/product/index.js";
99

1010
const signature: string = "e51bdf80f1a08ed44ee161100fc30a25cb35b4ede671b0a575dc9064a3f5dbf1";
1111
const dummySecretKey: string = "ogNjY44MhvKPGTtVsI8zG82JqWQa68woYQH";
12-
const filePath: string = path.join(V2_RESOURCE_PATH, "inference/standard_field_types.json");
12+
const filePath: string = path.join(V2_PRODUCT_PATH, "extraction/standard_field_types.json");
1313

1414
async function assertLocalResponse(localResponse: LocalResponse) {
1515
await localResponse.init();
@@ -49,8 +49,8 @@ describe("MindeeV2 - Load Local Response", () => {
4949

5050
it("loading an inference works on catalog model", async () => {
5151
const jsonPath = path.join(
52-
V2_RESOURCE_PATH,
53-
"products",
52+
V2_PRODUCT_PATH,
53+
"extraction",
5454
"financial_document",
5555
"complete.json"
5656
);

0 commit comments

Comments
 (0)