forked from aws/aws-sdk-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing the Machine Learning client to use the provided PredictEndpoin…
…t as the host for the Predict operation.
- Loading branch information
1 parent
0e44bb2
commit a51912a
Showing
2 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
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
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,37 @@ | ||
<?php | ||
namespace Aws\Test\MachineLearning; | ||
|
||
use Aws\Middleware; | ||
use Aws\MachineLearning\MachineLearningClient; | ||
use Aws\Test\UsesServiceTrait; | ||
use GuzzleHttp\Psr7; | ||
use GuzzleHttp\Psr7\Uri; | ||
|
||
/** | ||
* @covers Aws\MachineLearning\MachineLearningClient | ||
*/ | ||
class MachineLearningClientTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
use UsesServiceTrait; | ||
|
||
public function testUpdatesPredictEndpoint() | ||
{ | ||
// Setup state of command/request | ||
$predictEndpoint = new Uri('https://realtime.machinelearning.us-east-1.amazonaws.com/foo'); | ||
$client = new MachineLearningClient([ | ||
'region' => 'us-east-1', | ||
'version' => 'latest' | ||
]); | ||
$this->addMockResults($client, [[]]); | ||
$client->getHandlerList()->appendSign(Middleware::tap(function ($c, $r) use (&$command, &$request) { | ||
$command = $c; $request = $r; | ||
})); | ||
$client->predict([ | ||
'MLModelId' => 'foo', | ||
'Record' => ['foo' => 'bar'], | ||
'PredictEndpoint' => (string) $predictEndpoint | ||
]); | ||
|
||
$this->assertEquals($predictEndpoint->getHost(), $request->getUri()->getHost()); | ||
} | ||
} |