Spaces:
Sleeping
Sleeping
Clement Vachet
commited on
Commit
·
78adc20
1
Parent(s):
e0f980a
test: new test for lambda_handler function
Browse files- models/model.pkl +0 -0
- tests/test_lambda.py +31 -0
models/model.pkl
CHANGED
Binary files a/models/model.pkl and b/models/model.pkl differ
|
|
tests/test_lambda.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
import pytest
|
4 |
+
import json
|
5 |
+
|
6 |
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
7 |
+
parent_dir = os.path.dirname(current_dir)
|
8 |
+
sys.path.insert(0, os.path.dirname(parent_dir))
|
9 |
+
|
10 |
+
from lambda_function import lambda_handler
|
11 |
+
|
12 |
+
@pytest.fixture
|
13 |
+
def event():
|
14 |
+
json_event = {"body": "{\"features\": [[6.5, 3.0, 5.8, 2.2], [6.1, 2.8, 4.7, 1.2]]}"}
|
15 |
+
return json_event
|
16 |
+
|
17 |
+
@pytest.fixture
|
18 |
+
def context():
|
19 |
+
return None
|
20 |
+
|
21 |
+
@pytest.fixture
|
22 |
+
def response_prediction():
|
23 |
+
return ["virginica", "versicolor"]
|
24 |
+
|
25 |
+
|
26 |
+
def test_lambda_handler(event, context, response_prediction):
|
27 |
+
lambda_response = lambda_handler(event, context)
|
28 |
+
|
29 |
+
assert lambda_response["statusCode"] == 200
|
30 |
+
assert json.loads(lambda_response["body"])["predictions"] == response_prediction
|
31 |
+
|