File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from fastapi_scaffolding .core import config
4+ from fastapi_scaffolding .models .payload import HousePredictionPayload
5+ from fastapi_scaffolding .models .prediction import HousePredictionResult
6+ from fastapi_scaffolding .services .models import HousePriceModel
7+
8+
9+ def test_prediction (test_client ) -> None :
10+ model_path = config .DEFAULT_MODEL_PATH
11+ hpp = HousePredictionPayload .parse_obj ({
12+ "median_income_in_block" : 8.3252 ,
13+ "median_house_age_in_block" : 41 ,
14+ "average_rooms" : 6 ,
15+ "average_bedrooms" : 1 ,
16+ "population_per_block" : 322 ,
17+ "average_house_occupancy" : 2.55 ,
18+ "block_latitude" : 37.88 ,
19+ "block_longitude" : - 122.23
20+ })
21+
22+ hpm = HousePriceModel (model_path )
23+ result = hpm .predict (hpp )
24+ assert isinstance (result , HousePredictionResult )
25+
26+
27+ def test_prediction_no_payload (test_client ) -> None :
28+ model_path = config .DEFAULT_MODEL_PATH
29+
30+ hpm = HousePriceModel (model_path )
31+ with pytest .raises (ValueError ):
32+ result = hpm .predict (None )
33+ assert isinstance (result , HousePredictionResult )
You can’t perform that action at this time.
0 commit comments