Spaces:
Sleeping
Sleeping
File size: 909 Bytes
ca264b8 78adc20 ca264b8 78adc20 ca264b8 78adc20 ca264b8 78adc20 ca264b8 78adc20 ca264b8 78adc20 ca264b8 78adc20 ca264b8 78adc20 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
"""
Testing Lambda handler
"""
import os
import sys
import json
import pytest
from lambda_function import lambda_handler
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, os.path.dirname(parent_dir))
@pytest.fixture
def event():
"""Example json event"""
json_event = {"features": [[6.5, 3.0, 5.8, 2.2], [6.1, 2.8, 4.7, 1.2]]}
return json_event
@pytest.fixture
def context():
"""Example context"""
return None
@pytest.fixture
def response_prediction():
"""Ground truth - API response"""
return ["virginica", "versicolor"]
def test_lambda_handler(event, context, response_prediction):
"""Tests lambda handler"""
lambda_response = lambda_handler(event, context)
assert lambda_response["statusCode"] == 200
assert json.loads(lambda_response["body"])["predictions"] == response_prediction
|