-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add a basic test case for DocumentAIProcessor
- Loading branch information
Showing
3 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...documentai/v1alpha1/documentaiprocessor/_generated_object_documentaiprocessor.golden.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apiVersion: documentai.cnrm.cloud.google.com/v1alpha1 | ||
kind: DocumentAIProcessor | ||
metadata: | ||
finalizers: | ||
- cnrm.cloud.google.com/finalizer | ||
- cnrm.cloud.google.com/deletion-defender | ||
generation: 1 | ||
labels: | ||
cnrm-test: "true" | ||
name: documentaiprocessor-${uniqueId} | ||
namespace: ${uniqueId} | ||
spec: | ||
displayName: test-processor-${uniqueId} | ||
location: us | ||
projectRef: | ||
external: ${projectId} | ||
type: OCR_PROCESSOR | ||
status: | ||
conditions: | ||
- lastTransitionTime: "1970-01-01T00:00:00Z" | ||
message: The resource is up to date | ||
reason: UpToDate | ||
status: "True" | ||
type: Ready | ||
externalRef: projects/${projectNumber}/locations/us/processors/${processorID} | ||
observedGeneration: 1 | ||
observedState: | ||
createTime: "1970-01-01T00:00:00Z" | ||
defaultProcessorVersion: projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID} | ||
name: projects/${projectNumber}/locations/us/processors/${processorID} | ||
processEndpoint: https://us-documentai.googleapis.com/v1/projects/${projectNumber}/locations/us/processors/${processorID}:process | ||
processorVersionAliases: | ||
- alias: projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/pretrained | ||
processorVersion: projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID} | ||
- alias: projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/pretrained-next | ||
processorVersion: projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID} | ||
- alias: projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/rc | ||
processorVersion: projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID} | ||
- alias: projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/stable | ||
processorVersion: projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID} | ||
state: ENABLED |
197 changes: 197 additions & 0 deletions
197
pkg/test/resourcefixture/testdata/basic/documentai/v1alpha1/documentaiprocessor/_http.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
GET https://documentai.googleapis.com/v1/projects/${projectId}/locations/us/processors/${processorID}?%24alt=json%3Benum-encoding%3Dint | ||
Content-Type: application/json | ||
User-Agent: kcc/${kccVersion} (+https://github.com/GoogleCloudPlatform/k8s-config-connector) kcc/controller-manager/${kccVersion} | ||
X-Goog-Request-Params: name=projects%2F${projectId}%2Flocations%2Fus%2Fprocessors%2Fdocumentaiprocessor-${uniqueId} | ||
|
||
404 Not Found | ||
Content-Type: application/json; charset=UTF-8 | ||
Server: scaffolding on HTTPServer2 | ||
Vary: Origin | ||
Vary: X-Origin | ||
Vary: Referer | ||
X-Content-Type-Options: nosniff | ||
X-Frame-Options: SAMEORIGIN | ||
X-Xss-Protection: 0 | ||
|
||
{ | ||
"error": { | ||
"code": 404, | ||
"message": "Processor with id 'documentaiprocessor-${uniqueId}' not found.", | ||
"status": "NOT_FOUND" | ||
} | ||
} | ||
|
||
--- | ||
|
||
POST https://documentai.googleapis.com/v1/projects/${projectId}/locations/us/processors?%24alt=json%3Benum-encoding%3Dint | ||
Content-Type: application/json | ||
User-Agent: kcc/${kccVersion} (+https://github.com/GoogleCloudPlatform/k8s-config-connector) kcc/controller-manager/${kccVersion} | ||
X-Goog-Request-Params: parent=projects%2F${projectId}%2Flocations%2Fus | ||
|
||
{ | ||
"displayName": "test-processor-${uniqueId}", | ||
"type": "OCR_PROCESSOR" | ||
} | ||
|
||
200 OK | ||
Content-Type: application/json; charset=UTF-8 | ||
Server: scaffolding on HTTPServer2 | ||
Vary: Origin | ||
Vary: X-Origin | ||
Vary: Referer | ||
X-Content-Type-Options: nosniff | ||
X-Frame-Options: SAMEORIGIN | ||
X-Xss-Protection: 0 | ||
|
||
{ | ||
"createTime": "2024-04-01T12:34:56.123456Z", | ||
"defaultProcessorVersion": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID}", | ||
"displayName": "test-processor-${uniqueId}", | ||
"name": "projects/${projectNumber}/locations/us/processors/${processorID}", | ||
"processEndpoint": "https://us-documentai.googleapis.com/v1/projects/${projectNumber}/locations/us/processors/${processorID}:process", | ||
"processorVersionAliases": [ | ||
{ | ||
"alias": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/pretrained", | ||
"processorVersion": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID}" | ||
}, | ||
{ | ||
"alias": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/pretrained-next", | ||
"processorVersion": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID}" | ||
}, | ||
{ | ||
"alias": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/rc", | ||
"processorVersion": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID}" | ||
}, | ||
{ | ||
"alias": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/stable", | ||
"processorVersion": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID}" | ||
} | ||
], | ||
"state": 1, | ||
"type": "OCR_PROCESSOR" | ||
} | ||
|
||
--- | ||
|
||
GET https://documentai.googleapis.com/v1/projects/${projectNumber}/locations/us/processors/${processorID}?%24alt=json%3Benum-encoding%3Dint | ||
Content-Type: application/json | ||
User-Agent: kcc/${kccVersion} (+https://github.com/GoogleCloudPlatform/k8s-config-connector) kcc/controller-manager/${kccVersion} | ||
X-Goog-Request-Params: name=projects%2F${projectNumber}%2Flocations%2Fus%2Fprocessors%2F${processorID} | ||
|
||
200 OK | ||
Content-Type: application/json; charset=UTF-8 | ||
Server: scaffolding on HTTPServer2 | ||
Vary: Origin | ||
Vary: X-Origin | ||
Vary: Referer | ||
X-Content-Type-Options: nosniff | ||
X-Frame-Options: SAMEORIGIN | ||
X-Xss-Protection: 0 | ||
|
||
{ | ||
"createTime": "2024-04-01T12:34:56.123456Z", | ||
"defaultProcessorVersion": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID}", | ||
"displayName": "test-processor-${uniqueId}", | ||
"name": "projects/${projectNumber}/locations/us/processors/${processorID}", | ||
"processEndpoint": "https://us-documentai.googleapis.com/v1/projects/${projectNumber}/locations/us/processors/${processorID}:process", | ||
"processorVersionAliases": [ | ||
{ | ||
"alias": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/pretrained", | ||
"processorVersion": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID}" | ||
}, | ||
{ | ||
"alias": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/pretrained-next", | ||
"processorVersion": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID}" | ||
}, | ||
{ | ||
"alias": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/rc", | ||
"processorVersion": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID}" | ||
}, | ||
{ | ||
"alias": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/stable", | ||
"processorVersion": "projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/${processorVersionID}" | ||
} | ||
], | ||
"state": 1, | ||
"type": "OCR_PROCESSOR" | ||
} | ||
|
||
--- | ||
|
||
DELETE https://documentai.googleapis.com/v1/projects/${projectNumber}/locations/us/processors/${processorID}?%24alt=json%3Benum-encoding%3Dint | ||
Content-Type: application/json | ||
User-Agent: kcc/${kccVersion} (+https://github.com/GoogleCloudPlatform/k8s-config-connector) kcc/controller-manager/${kccVersion} | ||
X-Goog-Request-Params: name=projects%2F${projectNumber}%2Flocations%2Fus%2Fprocessors%2F${processorID} | ||
|
||
200 OK | ||
Content-Type: application/json; charset=UTF-8 | ||
Server: scaffolding on HTTPServer2 | ||
Vary: Origin | ||
Vary: X-Origin | ||
Vary: Referer | ||
X-Content-Type-Options: nosniff | ||
X-Frame-Options: SAMEORIGIN | ||
X-Xss-Protection: 0 | ||
|
||
{ | ||
"metadata": { | ||
"@type": "type.googleapis.com/google.cloud.documentai.v1.DeleteProcessorMetadata", | ||
"commonMetadata": { | ||
"createTime": "2025-01-01T12:34:56.123456Z", | ||
"resource": "projects/${projectNumber}/locations/us/processors/${processorID}", | ||
"state": 1, | ||
"updateTime": "2025-01-02T12:34:56.123456Z" | ||
} | ||
}, | ||
"name": "projects/${projectNumber}/locations/us/operations/${operationID}" | ||
} | ||
|
||
--- | ||
|
||
GET https://documentai.googleapis.com/v1/projects/${projectNumber}/locations/us/processors/${processorID}?%24alt=json%3Benum-encoding%3Dint | ||
Content-Type: application/json | ||
User-Agent: kcc/${kccVersion} (+https://github.com/GoogleCloudPlatform/k8s-config-connector) kcc/controller-manager/${kccVersion} | ||
X-Goog-Request-Params: name=projects%2F${projectNumber}%2Flocations%2Fus%2Fprocessors%2F${processorID} | ||
|
||
404 Not Found | ||
Content-Type: application/json; charset=UTF-8 | ||
Server: scaffolding on HTTPServer2 | ||
Vary: Origin | ||
Vary: X-Origin | ||
Vary: Referer | ||
X-Content-Type-Options: nosniff | ||
X-Frame-Options: SAMEORIGIN | ||
X-Xss-Protection: 0 | ||
|
||
{ | ||
"error": { | ||
"code": 404, | ||
"message": "Processor with id '${processorID}' not found.", | ||
"status": "NOT_FOUND" | ||
} | ||
} | ||
|
||
--- | ||
|
||
DELETE https://documentai.googleapis.com/v1/projects/${projectNumber}/locations/us/processors/${processorID}?%24alt=json%3Benum-encoding%3Dint | ||
Content-Type: application/json | ||
User-Agent: kcc/${kccVersion} (+https://github.com/GoogleCloudPlatform/k8s-config-connector) kcc/controller-manager/${kccVersion} | ||
X-Goog-Request-Params: name=projects%2F${projectNumber}%2Flocations%2Fus%2Fprocessors%2F${processorID} | ||
|
||
404 Not Found | ||
Content-Type: application/json; charset=UTF-8 | ||
Server: scaffolding on HTTPServer2 | ||
Vary: Origin | ||
Vary: X-Origin | ||
Vary: Referer | ||
X-Content-Type-Options: nosniff | ||
X-Frame-Options: SAMEORIGIN | ||
X-Xss-Protection: 0 | ||
|
||
{ | ||
"error": { | ||
"code": 404, | ||
"message": "Processor with id '${processorID}' not found.", | ||
"status": "NOT_FOUND" | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
pkg/test/resourcefixture/testdata/basic/documentai/v1alpha1/documentaiprocessor/create.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2025 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: documentai.cnrm.cloud.google.com/v1alpha1 | ||
kind: DocumentAIProcessor | ||
metadata: | ||
name: documentaiprocessor-${uniqueId} | ||
spec: | ||
projectRef: | ||
external: ${projectId} | ||
location: us | ||
displayName: test-processor-${uniqueId} | ||
type: OCR_PROCESSOR | ||
# we can update this field after we get processorID (service generated ID) | ||
# defaultProcessorVersion: projects/${projectNumber}/locations/us/processors/${processorID}/processorVersions/stable |