Merged in feature/textExtractionsPart3 (pull request #195)

enrich doc responses

* enrich doc responses
This commit is contained in:
Jay Brown
2025-12-11 14:25:51 +00:00
parent a94637ab13
commit 8c218f162b
22 changed files with 1797 additions and 363 deletions
+37 -22
View File
@@ -78,20 +78,33 @@ func TestProcess(t *testing.T) {
assert.Len(t, *docs.JSON200, 1)
doc := (*docs.JSON200)[0]
expectedDoc := queryapi.Document{
Id: doc.Id,
Hash: doc.Hash,
ClientId: clientId,
Fields: map[string]any{
"JSON_QUERY": "valueone",
},
}
docRes, err := net.Client.GetDocumentWithResponse(t.Context(), doc.Id)
docRes, err := net.Client.GetDocumentWithResponse(t.Context(), doc.Id, nil)
require.NoError(t, err)
require.NotNil(t, docRes)
require.NotNil(t, docRes.JSON200)
assert.EqualExportedValues(t, expectedDoc, *docRes.JSON200)
// Verify core document fields
assert.Equal(t, doc.Id, docRes.JSON200.Id)
assert.Equal(t, doc.Hash, docRes.JSON200.Hash)
assert.Equal(t, clientId, docRes.JSON200.ClientId)
assert.Equal(t, map[string]any{"JSON_QUERY": "valueone"}, docRes.JSON200.Fields)
assert.Equal(t, []queryapi.LabelRecord{}, docRes.JSON200.Labels)
// Verify enriched fields are populated (values depend on upload)
assert.NotNil(t, docRes.JSON200.Filename, "Filename should be populated")
assert.Equal(t, "helloworld.pdf", *docRes.JSON200.Filename)
assert.NotNil(t, docRes.JSON200.OriginalPath, "OriginalPath should be populated")
// Test with textRecord=true parameter
includeTextRecord := true
docResWithText, err := net.Client.GetDocumentWithResponse(t.Context(), doc.Id, &queryapi.GetDocumentParams{
TextRecord: &includeTextRecord,
})
require.NoError(t, err)
require.NotNil(t, docResWithText.JSON200)
// Document doesn't have a field extraction in this test, so hasTextRecord should be false
assert.False(t, docResWithText.JSON200.HasTextRecord)
assert.Nil(t, docResWithText.JSON200.TextRecord)
})
t.Run("update config", func(t *testing.T) {
cfg := &Config{}
@@ -158,20 +171,22 @@ func TestProcess(t *testing.T) {
assert.Len(t, *docs.JSON200, 1)
doc := (*docs.JSON200)[0]
expectedDoc := queryapi.Document{
Id: doc.Id,
Hash: doc.Hash,
ClientId: clientId,
Fields: map[string]any{
"JSON_QUERY": "valuetwo",
},
}
docRes, err := net.Client.GetDocumentWithResponse(t.Context(), doc.Id)
docRes, err := net.Client.GetDocumentWithResponse(t.Context(), doc.Id, nil)
require.NoError(t, err)
require.NotNil(t, docRes)
require.NotNil(t, docRes.JSON200)
assert.EqualExportedValues(t, expectedDoc, *docRes.JSON200)
// Verify core document fields
assert.Equal(t, doc.Id, docRes.JSON200.Id)
assert.Equal(t, doc.Hash, docRes.JSON200.Hash)
assert.Equal(t, clientId, docRes.JSON200.ClientId)
assert.Equal(t, map[string]any{"JSON_QUERY": "valuetwo"}, docRes.JSON200.Fields)
assert.Equal(t, []queryapi.LabelRecord{}, docRes.JSON200.Labels)
// Verify enriched fields are populated (values depend on upload)
assert.NotNil(t, docRes.JSON200.Filename, "Filename should be populated")
assert.Equal(t, "helloworld.pdf", *docRes.JSON200.Filename)
assert.NotNil(t, docRes.JSON200.OriginalPath, "OriginalPath should be populated")
})
t.Run("test multiple versions", func(t *testing.T) {
cfg := &Config{}