File tree Expand file tree Collapse file tree 1 file changed +17
-11
lines changed
tests/unit/sagemaker/serverless Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Original file line number Diff line number Diff line change 12
12
# language governing permissions and limitations under the License.
13
13
from __future__ import absolute_import
14
14
15
+ import io
15
16
from mock import Mock
16
17
import pytest
17
18
@@ -26,17 +27,22 @@ def mock_client():
26
27
27
28
28
29
def test_predict (mock_client ):
29
- # TODO
30
- # mock_client.create_function = Mock(return_value={"class": "cat"})
31
- # predictor = LambdaPredictor("my_function", mock_client)
32
- #
33
- # prediction = predictor.predict({"url": "https://images.com/cat.jpg"})
34
- #
35
- # assert prediction = {"class": "cat"}
36
- # mock_client.invoke.assert_called_once
37
- # _, kwargs = mock_client.delete_function.call_args
38
- # assert kwargs["FunctionName"] == "my-function"
39
- pass
30
+ mock_client .invoke = Mock (
31
+ return_value = {
32
+ "StatusCode" : 200 ,
33
+ "Payload" : io .BytesIO (b'{"class": "cat"}' ),
34
+ "ResponseMetadata" : {"HTTPHeaders" : {"content-type" : "application/json" }},
35
+ }
36
+ )
37
+ predictor = LambdaPredictor (FUNCTION_NAME , mock_client )
38
+
39
+ prediction = predictor .predict ({"url" : "https://images.com/cat.jpg" })
40
+
41
+ mock_client .invoke .assert_called_once
42
+ _ , kwargs = mock_client .invoke .call_args
43
+ assert kwargs ["FunctionName" ] == FUNCTION_NAME
44
+
45
+ assert prediction == {"class" : "cat" }
40
46
41
47
42
48
def test_destroy (mock_client ):
You can’t perform that action at this time.
0 commit comments