Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
MINDEE_ENDPOINT_SE_TESTS: ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }}
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
WORKFLOW_ID: ${{ secrets.WORKFLOW_ID_SE_TESTS }}

jobs:
integration-tests-ubuntu:
name: Run Integration Tests on Ubuntu
Expand Down
20 changes: 14 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,12 @@ private function makeEnqueueRequest(
);
}
}
$response = ResponseValidation::cleanRequestData($options->endpoint->predictAsyncRequestPost(
$inputDoc,
$options
));
$response = ResponseValidation::cleanRequestData(
$options->endpoint->predictAsyncRequestPost(
$inputDoc,
$options
)
);
if (!ResponseValidation::isValidAsyncResponse($response)) {
throw MindeeHttpException::handleError(
$options->endpoint->settings->endpointName,
Expand Down Expand Up @@ -436,7 +438,13 @@ public function enqueueAndParse(
$options->endpoint = $options->endpoint ?? $this->constructOTSEndpoint(
$predictionType,
);
$enqueueResponse = $this->enqueue($predictionType, $inputDoc, $options, $pageOptions);

$enqueueResponse = $this->enqueue(
$predictionType,
$inputDoc,
$options,
$pageOptions
);
error_log("Successfully enqueued document with job id: " . $enqueueResponse->job->id);

sleep($asyncOptions->initialDelaySec);
Expand All @@ -455,7 +463,7 @@ public function enqueueAndParse(
if ($pollResults->job->status != "completed") {
throw new MindeeApiException(
"Couldn't retrieve document " . $enqueueResponse->job->id . " after $retryCounter tries.",
ErrorCode::API_TIMEOUT
ErrorCode::API_TIMEOUT,
);
}
return $pollResults;
Expand Down
3 changes: 2 additions & 1 deletion src/Http/BaseEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ public function setFinalCurlOpts(
?array $postFields,
?string $workflowId = null
): array {
$url = $this->settings->urlRoot . $suffix;
if (isset($workflowId)) {
$url = $this->settings->baseUrl . "/workflows/" . $workflowId . $suffix;
} else {
$url = $this->settings->urlRoot . $suffix;
}
curl_setopt($ch, CURLOPT_URL, $url);
if ($postFields !== null) {
Expand Down
13 changes: 7 additions & 6 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,22 @@ class ClientTest extends TestCase

protected function setUp(): void
{
$rootPath = (getenv('GITHUB_WORKSPACE') ?: ".");
$this->oldKey = getenv('MINDEE_API_KEY');
$this->dummyClient = new Client("dummy-key");
putenv('MINDEE_API_KEY=');
$this->emptyClient = new Client();
putenv('MINDEE_API_KEY=dummy-env-key');
$this->envClient = new Client();
$this->fileTypesDir = (
getenv('GITHUB_WORKSPACE') ?: "."
) . "/tests/resources/file_types/";
$rootPath . "/tests/resources/file_types/"
);
$this->invoicePath = (
getenv('GITHUB_WORKSPACE') ?: "."
) . "/tests/resources/products/invoices/response_v4/complete.json";
$rootPath . "/tests/resources/products/invoices/response_v4/complete.json"
);
$this->failedJobPath = (
getenv('GITHUB_WORKSPACE') ?: "."
) . "/tests/resources/async/get_failed_job_error.json";
$rootPath . "/tests/resources/async/get_failed_job_error.json"
);
}


Expand Down
9 changes: 5 additions & 4 deletions tests/Workflow/WorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ class WorkflowTest extends TestCase

protected function setUp(): void
{
$rootPath = (getenv('GITHUB_WORKSPACE') ?: ".");
$this->findocSamplePath = (
getenv('GITHUB_WORKSPACE') ?: "."
) . "/tests/resources/products/financial_document/default_sample.jpg";
$rootPath . "/tests/resources/products/financial_document/default_sample.jpg"
);
$this->workflowDir = (
getenv('GITHUB_WORKSPACE') ?: "."
) . "/tests/resources/workflows/";
$rootPath . "/tests/resources/workflows/"
);
}

public function testDeserializeWorkflow()
Expand Down
13 changes: 9 additions & 4 deletions tests/Workflow/WorkflowTestFunctional.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ class WorkflowTestFunctional extends TestCase
private $workflowId;
private $mindeeClient;
private $inputSource;
private $predictionType;

protected function setUp(): void
{
$rootPath = (getenv('GITHUB_WORKSPACE') ?: ".");
$this->mindeeClient = new Client();
$this->workflowId = getenv('WORKFLOW_ID') ?: '';
$this->predictionType = FinancialDocumentV1::class;
$this->inputSource = $this->mindeeClient->sourceFromPath(
(getenv('GITHUB_WORKSPACE') ?: ".") . "/tests/resources/products/financial_document/default_sample.jpg"
$rootPath . "/tests/resources/products/financial_document/default_sample.jpg"
);
}

Expand All @@ -34,7 +37,9 @@ public function testWorkflow() {
null,
true
);
$response = $this->mindeeClient->executeWorkflow($this->inputSource, $this->workflowId, $options);
$response = $this->mindeeClient->executeWorkflow(
$this->inputSource, $this->workflowId, $options
);
$this->assertEquals(202, $response->apiRequest->statusCode);
$this->assertEquals("php-$currentDateTime", $response->execution->file->alias);
$this->assertEquals("low", $response->execution->priority);
Expand All @@ -44,7 +49,7 @@ public function testWorkflowPollingWithRAG() {
$options = new PredictMethodOptions();
$options->setRAG(true)->setWorkflowId($this->workflowId);
$response = $this->mindeeClient->enqueueAndParse(
FinancialDocumentV1::class,
$this->predictionType,
$this->inputSource,
$options
);
Expand All @@ -57,7 +62,7 @@ public function testWorkflowPollingWithoutRAG() {
$options = new PredictMethodOptions();
$options->setWorkflowId($this->workflowId);
$response = $this->mindeeClient->enqueueAndParse(
FinancialDocumentV1::class,
$this->predictionType,
$this->inputSource,
$options
);
Expand Down